view libervia_server/libervia.sh @ 392:f539f6f8ee9c

browser_side: standardize the dialogs size and buttons display: - do not set a default width/height for the XMLUI dialogs - do not display an extra "Close" button when XMLUI form is showed - the buttons order is OK/Save on the left, Cancel/Close on the right - horizontally center the dialog buttons
author souliane <souliane@mailoo.org>
date Mon, 03 Mar 2014 16:24:00 +0100
parents 9834136b15ed
children 2bd609d7dd65
line wrap: on
line source

#!/bin/sh

#if there is one argument which is "stop", then we kill libervia
DEBUG=""
if [ $# -eq 1 ];then
    if [ $1 = "stop" ];then
        echo "Terminating Libervia"
        pkill -f "twistd.*libervia"
        exit 0
    fi
    if [ $1 = "debug" ];then
        echo "Launching Libervia in debug mode"
        DEBUG="--debug"
    fi
fi

NAME='libervia'
PYTHON='python'

#We use python to parse config files
eval `"$PYTHON" << PYTHONEND
from ConfigParser import SafeConfigParser
from os.path import expanduser, join
import sys

config = SafeConfigParser(defaults={'local_dir':'~/.libervia',
                                    'pid_dir':'/tmp',
                                    'log_dir':'%(local_dir)s'})
try:
    config.read(map(expanduser, ['/etc/libervia.conf', '~/libervia.conf', '~/.libervia.conf', 'libervia.conf', '.libervia.conf']))
except:
    print ("echo \"/!\\ Can't read main config ! Please check the syntax\";")
    print ("exit 1")
    sys.exit()

env=[]
env.append("LOCAL_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'local_dir')),''))
env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),''))
env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),''))

print ";".join(env)
PYTHONEND
`

PID_FILE="$PID_DIR$NAME.pid"
LOG_FILE="$LOCAL_DIR$NAME.log"
DAEMON="n"
MAIN_OPTIONS="-${DAEMON}o"

#Don't change the next line
AUTO_OPTIONS=""
ADDITIONAL_OPTIONS="--pidfile $PID_FILE --logfile $LOG_FILE $AUTO_OPTIONS $DEBUG"

log_dir=`dirname "$LOG_FILE"`
if [ ! -d $log_dir ] ; then
    mkdir $log_dir
fi

echo "Starting Libervia..."
twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $NAME