Mercurial > libervia-backend
changeset 369:e83d0c21d64d
launching script now read config files
added ./sat.conf in possible config file location
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 19 Jun 2011 17:40:36 +0200 (2011-06-19) |
parents | d9499d27f884 |
children | 68cdaf6d78e3 |
files | src/sat.sh src/tools/memory.py |
diffstat | 2 files changed, 20 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/sat.sh Sat Jun 18 23:28:10 2011 +0200 +++ b/src/sat.sh Sun Jun 19 17:40:36 2011 +0200 @@ -16,14 +16,25 @@ 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="./"
--- a/src/tools/memory.py Sat Jun 18 23:28:10 2011 +0200 +++ b/src/tools/memory.py Sun Jun 19 17:40:36 2011 +0200 @@ -410,7 +410,7 @@ """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 !"))