1
|
#! /bin/sh
|
2
|
### BEGIN INIT INFO
|
3
|
# Provides: wcs-auquotidien
|
4
|
# Required-Start: $local_fs $network
|
5
|
# Required-Stop: $local_fs $network
|
6
|
# Default-Start: 2 3 4 5
|
7
|
# Default-Stop: 0 1 6
|
8
|
# Short-Description: w.c.s. (Au quotidien)
|
9
|
# Description: w.c.s. Form Server (with Au Quotidien Extension)
|
10
|
### END INIT INFO
|
11
|
|
12
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
13
|
DESC="w.c.s. (+Au Quotidien)"
|
14
|
NAME=wcs-auquotidien
|
15
|
DAEMON=/usr/sbin/wcsctl
|
16
|
PIDFILE=/var/run/$NAME.pid
|
17
|
SCRIPTNAME=/etc/init.d/$NAME
|
18
|
PYTHON_VERSION=`/usr/bin/env python -c \
|
19
|
"import sys; print '%d.%d' % (sys.version_info[0], sys.version_info[1])"`
|
20
|
OPTIONS="--extra /usr/lib/pymodules/python$PYTHON_VERSION/extra-wcs-au-quotidien/"
|
21
|
WCS_USER=wcs-au-quotidien
|
22
|
WCS_GROUP=wcs-au-quotidien
|
23
|
CONFIG_FILE=/etc/wcs/wcs-au-quotidien.cfg
|
24
|
|
25
|
# Gracefully exit if the package has been removed.
|
26
|
test -x $DAEMON || exit 0
|
27
|
|
28
|
# Read config file if it is present.
|
29
|
if [ -r /etc/default/$NAME ]
|
30
|
then
|
31
|
. /etc/default/$NAME
|
32
|
fi
|
33
|
|
34
|
#
|
35
|
# Function that starts the daemon/service.
|
36
|
#
|
37
|
d_start() {
|
38
|
if [ $CONFIG_FILE ]; then
|
39
|
start-stop-daemon --start --quiet --pidfile $PIDFILE \
|
40
|
--chuid $WCS_USER:$WCS_GROUP --make-pidfile --background \
|
41
|
--exec $DAEMON -- -f $CONFIG_FILE start $OPTIONS
|
42
|
else
|
43
|
start-stop-daemon --start --quiet --pidfile $PIDFILE \
|
44
|
--chuid $WCS_USER:$WCS_GROUP --make-pidfile --background \
|
45
|
--exec $DAEMON -- start $OPTIONS
|
46
|
fi
|
47
|
}
|
48
|
|
49
|
#
|
50
|
# Function that stops the daemon/service.
|
51
|
#
|
52
|
d_stop() {
|
53
|
start-stop-daemon --stop --quiet --pidfile $PIDFILE
|
54
|
}
|
55
|
|
56
|
#
|
57
|
# Function that sends a SIGHUP to the daemon/service.
|
58
|
#
|
59
|
d_reload() {
|
60
|
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
|
61
|
--make-pidfile --background --signal 1
|
62
|
}
|
63
|
|
64
|
case "$1" in
|
65
|
start)
|
66
|
echo -n "Starting $DESC: $NAME"
|
67
|
d_start
|
68
|
echo "."
|
69
|
;;
|
70
|
stop)
|
71
|
echo -n "Stopping $DESC: $NAME"
|
72
|
d_stop
|
73
|
echo "."
|
74
|
;;
|
75
|
#reload)
|
76
|
#
|
77
|
# If the daemon can reload its configuration without
|
78
|
# restarting (for example, when it is sent a SIGHUP),
|
79
|
# then implement that here.
|
80
|
#
|
81
|
# If the daemon responds to changes in its config file
|
82
|
# directly anyway, make this an "exit 0".
|
83
|
#
|
84
|
# echo -n "Reloading $DESC configuration..."
|
85
|
# d_reload
|
86
|
# echo "done."
|
87
|
#;;
|
88
|
restart|force-reload)
|
89
|
#
|
90
|
# If the "reload" option is implemented, move the "force-reload"
|
91
|
# option to the "reload" entry above. If not, "force-reload" is
|
92
|
# just the same as "restart".
|
93
|
#
|
94
|
echo -n "Restarting $DESC: $NAME"
|
95
|
d_stop
|
96
|
sleep 1
|
97
|
d_start
|
98
|
echo "."
|
99
|
;;
|
100
|
*)
|
101
|
# echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
|
102
|
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
|
103
|
exit 1
|
104
|
;;
|
105
|
esac
|
106
|
|
107
|
exit 0
|