wok view openerp-server/stuff/etc/init.d/openerp-server @ rev 16681

Create some /var/run/<dir> in /etc/init.d/<daemon> scritps
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun May 18 20:24:07 2014 +0000 (2014-05-18)
parents 1b6281d68d9f
children 7f188676b59c
line source
1 #!/bin/sh
2 # /etc/init.d/openerp-server : Start, stop and restart OpenERP server on SliTaz, at
3 # boot time or with the command line.
4 #
5 # To start OpenERP server at boot time, just put openerp-server in the $RUN_DAEMONS
6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf
7 #
8 . /etc/init.d/rc.functions
9 . /etc/daemons.conf
11 NAME=OpenERP
12 DESC="OpenERP server"
13 DAEMON=/usr/bin/openerp-server
14 OPTIONS=$OPENERP_OPTIONS
15 PIDFILE=/var/run/openerp/openerp-server.pid
16 LOGFILE=/var/log/openerp/openerp-server.log
17 CONFIGFILE=/etc/openerp/openerp-server.cfg
19 if [ -z "$OPTIONS" ]; then
20 OPTIONS="--pidfile=$PIDFILE --logfile=$LOGFILE -c $CONFIGFILE"
21 LANG=$(. /etc/locale.conf; echo $LANG)
22 [ -f /usr/lib/python*/site-packages/tinyerp-server/i18n/$LANG.csv ] && \
23 OPTIONS="$OPTIONS -l $LANG"
24 fi
26 if [ ! -d /var/run/openerp ]; then
27 mkdir -p /var/run/openerp
28 chmod 777 /var/run/openerp
29 fi
30 case "$1" in
31 start)
32 if active_pidfile $PIDFILE python ; then
33 echo "$NAME already running (PID: `cat $PIDFILE`)."
34 exit 1
35 fi
36 echo -n "Starting $DESC: $NAME... "
37 $DAEMON $OPTIONS &
38 status
39 sleep 4
40 # At boot OpenERP dont start correctly if we start it in background.
41 if ! active_pidfile $PIDFILE python ; then
42 sleep 6
43 $DAEMON $OPTIONS > $LOGFILE
44 fi ;;
45 stop)
46 if ! active_pidfile $PIDFILE python ; then
47 echo "$NAME is not running."
48 exit 1
49 fi
50 echo -n "Stopping $DESC: $NAME... "
51 kill `cat $PIDFILE`
52 rm -f $PIDFILE
53 status
54 sleep 2 ;;
55 restart)
56 if ! active_pidfile $PIDFILE python ; then
57 echo "$NAME is not running."
58 exit 1
59 fi
60 echo -n "Restarting $DESC: $NAME... "
61 kill `cat $PIDFILE`
62 rm -f $PIDFILE 2> /dev/null
63 sleep 2
64 $DAEMON $OPTIONS &
65 status
66 sleep 2 ;;
67 *)
68 echo ""
69 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
70 echo ""
71 exit 1 ;;
72 esac
74 exit 0