comparison libervia_server/libervia.sh @ 360:9834136b15ed

added setup.py for the installation with setuptools
author souliane <souliane@mailoo.org>
date Tue, 18 Feb 2014 00:15:43 +0100
parents
children 2bd609d7dd65
comparison
equal deleted inserted replaced
359:151bf1afd97e 360:9834136b15ed
1 #!/bin/sh
2
3 #if there is one argument which is "stop", then we kill libervia
4 DEBUG=""
5 if [ $# -eq 1 ];then
6 if [ $1 = "stop" ];then
7 echo "Terminating Libervia"
8 pkill -f "twistd.*libervia"
9 exit 0
10 fi
11 if [ $1 = "debug" ];then
12 echo "Launching Libervia in debug mode"
13 DEBUG="--debug"
14 fi
15 fi
16
17 NAME='libervia'
18 PYTHON='python'
19
20 #We use python to parse config files
21 eval `"$PYTHON" << PYTHONEND
22 from ConfigParser import SafeConfigParser
23 from os.path import expanduser, join
24 import sys
25
26 config = SafeConfigParser(defaults={'local_dir':'~/.libervia',
27 'pid_dir':'/tmp',
28 'log_dir':'%(local_dir)s'})
29 try:
30 config.read(map(expanduser, ['/etc/libervia.conf', '~/libervia.conf', '~/.libervia.conf', 'libervia.conf', '.libervia.conf']))
31 except:
32 print ("echo \"/!\\ Can't read main config ! Please check the syntax\";")
33 print ("exit 1")
34 sys.exit()
35
36 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')),''))
39 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),''))
40
41 print ";".join(env)
42 PYTHONEND
43 `
44
45 PID_FILE="$PID_DIR$NAME.pid"
46 LOG_FILE="$LOCAL_DIR$NAME.log"
47 DAEMON="n"
48 MAIN_OPTIONS="-${DAEMON}o"
49
50 #Don't change the next line
51 AUTO_OPTIONS=""
52 ADDITIONAL_OPTIONS="--pidfile $PID_FILE --logfile $LOG_FILE $AUTO_OPTIONS $DEBUG"
53
54 log_dir=`dirname "$LOG_FILE"`
55 if [ ! -d $log_dir ] ; then
56 mkdir $log_dir
57 fi
58
59 echo "Starting Libervia..."
60 twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $NAME