comparison src/sat.sh @ 930:cbf4122baae7

core, memory: use XDG recommended paths as the defaults for the config and local directories
author souliane <souliane@mailoo.org>
date Sun, 23 Mar 2014 22:43:43 +0100
parents 952322b1d490
children 3b30e9f83d88
comparison
equal deleted inserted replaced
929:059b56cbd247 930:cbf4122baae7
17 NAME='sat' 17 NAME='sat'
18 PYTHON='python' 18 PYTHON='python'
19 19
20 #We use python to parse config files 20 #We use python to parse config files
21 eval `"$PYTHON" << PYTHONEND 21 eval `"$PYTHON" << PYTHONEND
22 from sat.core.constants import Const
22 from ConfigParser import SafeConfigParser 23 from ConfigParser import SafeConfigParser
23 from os.path import expanduser, join 24 from os.path import expanduser, join
24 import sys 25 import sys
25 26
26 config = SafeConfigParser(defaults={'local_dir':'~/.sat', 27 config = SafeConfigParser(defaults=Const.DEFAULT_CONFIG)
27 'pid_dir':'/tmp',
28 'log_dir':'%(local_dir)s'})
29 try: 28 try:
30 config.read(map(expanduser, ['/etc/sat.conf', '~/sat.conf', '~/.sat.conf', 'sat.conf', '.sat.conf'])) 29 config.read(Const.CONFIG_FILES)
31 except: 30 except:
32 print ("echo \"/!\\ Can't read main config ! Please check the syntax\";") 31 print ("echo \"/!\\ Can't read main config ! Please check the syntax\";")
33 print ("exit 1") 32 print ("exit 1")
34 sys.exit() 33 sys.exit()
35 34
36 env=[] 35 env=[]
37 env.append("LOCAL_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'local_dir')),''))
38 env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')) 36 env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),''))
39 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')) 37 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),''))
40 38
41 print ";".join(env) 39 print ";".join(env)
42 PYTHONEND 40 PYTHONEND
43 ` 41 `
44 42
45 PID_FILE="$PID_DIR$NAME.pid" 43 PID_FILE="$PID_DIR$NAME.pid"
46 LOG_FILE="$LOCAL_DIR$NAME.log" 44 LOG_FILE="$LOG_DIR$NAME.log"
47 DAEMON="n" 45 DAEMON="n"
48 MAIN_OPTIONS="-${DAEMON}oy" 46 MAIN_OPTIONS="-${DAEMON}oy"
49 TAP_PATH="./" 47 TAP_PATH="./"
50 TAP_FILE="$NAME.tac" 48 TAP_FILE="$NAME.tac"
51 49