comparison libervia_server/libervia.sh @ 417:2bd609d7dd65

server_side: use XDG recommended paths as the defaults
author souliane <souliane@mailoo.org>
date Sun, 23 Mar 2014 23:05:23 +0100
parents 9834136b15ed
children ec8775575886
comparison
equal deleted inserted replaced
416:e9bc7854bce6 417:2bd609d7dd65
17 NAME='libervia' 17 NAME='libervia'
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':'~/.libervia', 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/libervia.conf', '~/libervia.conf', '~/.libervia.conf', 'libervia.conf', '.libervia.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}o" 46 MAIN_OPTIONS="-${DAEMON}o"
49 47
50 #Don't change the next line 48 #Don't change the next line
51 AUTO_OPTIONS="" 49 AUTO_OPTIONS=""