launching script now read config files

added ./sat.conf in possible config file location
This commit is contained in:
Goffi 2011-06-19 17:40:36 +02:00
commit e4586d5a07
2 changed files with 20 additions and 9 deletions

View file

@ -16,14 +16,25 @@ fi
NAME='sat'
if [ -n "$SAT_CONST_local_dir" ];then
echo "Using overidded local dir: $SAT_CONST_local_dir"
PID_FILE="$SAT_CONST_local_dir/$NAME.pid"
LOG_FILE="$SAT_CONST_local_dir/$NAME.log"
else
PID_FILE="/tmp/$NAME.pid"
LOG_FILE=~/".$NAME/$NAME.log"
fi
#We use python to parse config files
eval `python<<PYTHONEND
from ConfigParser import SafeConfigParser
from os.path import expanduser, join
config = SafeConfigParser(defaults={'local_dir':'~/.sat',
'pid_dir':'/tmp',
'log_dir':'%(local_dir)s'})
try:
config.read(map(expanduser, ['/etc/sat.conf', '~/sat.conf', '~/.sat.conf', 'sat.conf', '.sat.conf']))
except:
print ("Can't read main config !")
print "LOCAL_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'local_dir')),'')
print "PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')
print "LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')
PYTHONEND
`
PID_FILE="$PID_DIR$NAME.pid"
LOG_FILE="$LOCAL_DIR$NAME.log"
DAEMON="n"
MAIN_OPTIONS="-${DAEMON}oy"
TAP_PATH="./"

View file

@ -410,7 +410,7 @@ class Memory:
"""look for main .ini configuration file, and parse it"""
_config = SafeConfigParser(defaults=default_config)
try:
_config.read(map(os.path.expanduser, ['/etc/sat.conf', '~/sat.conf', '~/.sat.conf', '.sat.conf']))
_config.read(map(os.path.expanduser, ['/etc/sat.conf', '~/sat.conf', '~/.sat.conf', 'sat.conf', '.sat.conf']))
except:
error (_("Can't read main config !"))