Mercurial > libervia-backend
annotate 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 |
rev | line source |
---|---|
4 | 1 #!/bin/sh |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
2 |
234
a7079e835432
added stop command in sat.sh launching script
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
3 #if there is one argument which is "stop", then we kill SàT |
249
0ed5553b5313
added "debug" command to sat launcher script
Goffi <goffi@goffi.org>
parents:
234
diff
changeset
|
4 DEBUG="" |
234
a7079e835432
added stop command in sat.sh launching script
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
5 if [ $# -eq 1 ];then |
a7079e835432
added stop command in sat.sh launching script
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
6 if [ $1 = "stop" ];then |
a7079e835432
added stop command in sat.sh launching script
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
7 echo "Terminating Salut à Toi" |
315 | 8 pkill -f "twistd.*/sat.tac" |
234
a7079e835432
added stop command in sat.sh launching script
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
9 exit 0 |
a7079e835432
added stop command in sat.sh launching script
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
10 fi |
249
0ed5553b5313
added "debug" command to sat launcher script
Goffi <goffi@goffi.org>
parents:
234
diff
changeset
|
11 if [ $1 = "debug" ];then |
0ed5553b5313
added "debug" command to sat launcher script
Goffi <goffi@goffi.org>
parents:
234
diff
changeset
|
12 echo "Launching SàT in debug mode" |
0ed5553b5313
added "debug" command to sat launcher script
Goffi <goffi@goffi.org>
parents:
234
diff
changeset
|
13 DEBUG="--debug" |
0ed5553b5313
added "debug" command to sat launcher script
Goffi <goffi@goffi.org>
parents:
234
diff
changeset
|
14 fi |
234
a7079e835432
added stop command in sat.sh launching script
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
15 fi |
a7079e835432
added stop command in sat.sh launching script
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
16 |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
17 NAME='sat' |
473
a11cde0cdf5b
misc: Make the shell launcher use the same python interpreter than setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
463
diff
changeset
|
18 PYTHON='python' |
4 | 19 |
369
e83d0c21d64d
launching script now read config files
Goffi <goffi@goffi.org>
parents:
358
diff
changeset
|
20 #We use python to parse config files |
473
a11cde0cdf5b
misc: Make the shell launcher use the same python interpreter than setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
463
diff
changeset
|
21 eval `"$PYTHON" << PYTHONEND |
930
cbf4122baae7
core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents:
587
diff
changeset
|
22 from sat.core.constants import Const |
369
e83d0c21d64d
launching script now read config files
Goffi <goffi@goffi.org>
parents:
358
diff
changeset
|
23 from ConfigParser import SafeConfigParser |
e83d0c21d64d
launching script now read config files
Goffi <goffi@goffi.org>
parents:
358
diff
changeset
|
24 from os.path import expanduser, join |
463 | 25 import sys |
369
e83d0c21d64d
launching script now read config files
Goffi <goffi@goffi.org>
parents:
358
diff
changeset
|
26 |
930
cbf4122baae7
core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents:
587
diff
changeset
|
27 config = SafeConfigParser(defaults=Const.DEFAULT_CONFIG) |
369
e83d0c21d64d
launching script now read config files
Goffi <goffi@goffi.org>
parents:
358
diff
changeset
|
28 try: |
930
cbf4122baae7
core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents:
587
diff
changeset
|
29 config.read(Const.CONFIG_FILES) |
369
e83d0c21d64d
launching script now read config files
Goffi <goffi@goffi.org>
parents:
358
diff
changeset
|
30 except: |
463 | 31 print ("echo \"/!\\ Can't read main config ! Please check the syntax\";") |
32 print ("exit 1") | |
33 sys.exit() | |
34 | |
35 env=[] | |
36 env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')) | |
930
cbf4122baae7
core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents:
587
diff
changeset
|
37 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),'')) |
463 | 38 |
39 print ";".join(env) | |
369
e83d0c21d64d
launching script now read config files
Goffi <goffi@goffi.org>
parents:
358
diff
changeset
|
40 PYTHONEND |
e83d0c21d64d
launching script now read config files
Goffi <goffi@goffi.org>
parents:
358
diff
changeset
|
41 ` |
463 | 42 |
369
e83d0c21d64d
launching script now read config files
Goffi <goffi@goffi.org>
parents:
358
diff
changeset
|
43 PID_FILE="$PID_DIR$NAME.pid" |
930
cbf4122baae7
core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents:
587
diff
changeset
|
44 LOG_FILE="$LOG_DIR$NAME.log" |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
45 DAEMON="n" |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
46 MAIN_OPTIONS="-${DAEMON}oy" |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
47 TAP_PATH="./" |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
48 TAP_FILE="$NAME.tac" |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
49 |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
50 #Don't change the next line |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
51 AUTO_OPTIONS="" |
249
0ed5553b5313
added "debug" command to sat launcher script
Goffi <goffi@goffi.org>
parents:
234
diff
changeset
|
52 ADDITIONAL_OPTIONS="--pidfile $PID_FILE --logfile $LOG_FILE $AUTO_OPTIONS $DEBUG" |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
53 |
226
d8bb72f00eec
distutils install: fixed plugin import and log file path
Goffi <goffi@goffi.org>
parents:
225
diff
changeset
|
54 log_dir=`dirname "$LOG_FILE"` |
d8bb72f00eec
distutils install: fixed plugin import and log file path
Goffi <goffi@goffi.org>
parents:
225
diff
changeset
|
55 if [ ! -d $log_dir ] ; then |
d8bb72f00eec
distutils install: fixed plugin import and log file path
Goffi <goffi@goffi.org>
parents:
225
diff
changeset
|
56 mkdir $log_dir |
d8bb72f00eec
distutils install: fixed plugin import and log file path
Goffi <goffi@goffi.org>
parents:
225
diff
changeset
|
57 fi |
d8bb72f00eec
distutils install: fixed plugin import and log file path
Goffi <goffi@goffi.org>
parents:
225
diff
changeset
|
58 |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
473
diff
changeset
|
59 twistd $MAIN_OPTIONS $TAP_PATH$TAP_FILE $ADDITIONAL_OPTIONS |