* Set all version numbers to 7.41 for upcoming beta.
[citadel.git] / webcit / debian / webcit.init
blob123d096c025dcb2950e0da4edd4ef9d2ec419625
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides: webcit
4 # Required-Start: $local_fs $remote_fs
5 # Required-Stop: $local_fs $remote_fs
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6
8 # Short-Description: Example initscript
9 # Description: This file should be used to construct scripts to be
10 # placed in /etc/init.d.
11 ### END INIT INFO
13 # Author: Wilfried Goesgens <citadel@outgesourced.org>
14 RUNDIR=/var/run/webcit
15 PATH=/sbin:/usr/sbin:/bin:/usr/bin
16 DESC="Citadel Groupware Webserver "
17 NAME=webcit
18 DAEMON=/usr/sbin/$NAME
19 DAEMON_ARGS=""
20 PIDFILE=$RUNDIR/$NAME.pid
21 SCRIPTNAME=/etc/init.d/webcit
22 SENDCOMMAND=/usr/sbin/sendcommand
23 DEFAULT=/etc/default/webcit
24 LOGDIR=/var/log/webcit/
27 unset LANG
28 unset LANGUAGE
29 unset LC_ALL
30 unset LOCALE
31 # Exit if the package is not installed
32 [ -x "$DAEMON" ] || exit 0
34 # Read configuration variable file if it is present
35 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
37 MODERN=
39 # Load the VERBOSE setting and other rcS variables
40 if test -f /lib/init/vars.sh ; then
41 . /lib/init/vars.sh
42 MODERN=1
45 # Define LSB log_* functions.
46 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
47 if test -f /lib/lsb/init-functions; then
48 . /lib/lsb/init-functions
49 MODERN=1
52 if test -f $DEFAULT; then
53 . $DEFAULT
56 if test -z "$TZ"; then
57 if test -e /etc/timezone; then
58 TZ=`cat /etc/timezone`
59 export TZ
63 # Function that starts the daemon/service
65 do_start()
67 #1: -p flag
68 #1: port
69 #2: ssl
70 #4: -f flag for apache
72 # for ubuntu: check our volatile dirs.
73 if test ! -d $RUNDIR; then
74 mkdir -p $RUNDIR
77 if test ! -d $LOGDIR; then
78 mkdir -p $LOGDIR
81 # are we disabled?
82 if test "$1" -lt "0"; then
83 return 0
86 # Return
87 # 0 if daemon has been started
88 # 1 if daemon was already running
89 # 2 if daemon could not be started
90 if $DAEMON -D$PIDFILE.$1 \
91 -p$@ -t$LOGDIR/access.${1}.log $4; then
92 return 0
93 else
94 return 2
99 # Function that stops the daemon/service
101 do_stop()
103 for i in $PIDFILE.*; do if test -f $i; then
104 kill `cat $i`
105 rm -f $i
106 fi; done
109 do_reload() {
110 do_stop
111 do_start
112 return 0
115 case "$1" in
116 start)
117 if test -n "$MODERN"; then
118 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
119 else
120 echo "Starting $DESC" "$NAME"
123 if test -n "$WEBCIT_LISTEN_IP"; then
124 LISTEN="-i$WEBCIT_LISTEN_IP"
127 do_start $WEBCIT_HTTP_PORT $WEBCIT_CITADEL_IP $WEBCIT_CITADEL_PORT "" "$LISTEN" "$WEBCIT_APACHEFLAG"
128 do_start $WEBCIT_HTTPS_PORT $WEBCIT_CITADEL_IP $WEBCIT_CITADEL_PORT -s "$LISTEN" "$WEBCIT_APACHEFLAG"
130 if test -n "$MODERN"; then
131 case "$?" in
132 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
133 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
134 esac
137 stop)
138 if test -n "$MODERN"; then
139 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
140 else
141 echo "Stopping $DESC" "$NAME"
143 do_stop
144 if test -n "$MODERN"; then
145 case "$?" in
146 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
147 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
148 esac
151 restart|force-reload)
152 if test -n "$MODERN"; then
153 log_daemon_msg "Restarting $DESC" "$NAME"
154 else
155 echo "Restarting $DESC" "$NAME"
158 do_stop
160 if test -n "$MODERN"; then
161 case "$?" in
162 0|1)
163 do_start $WEBCIT_HTTP_PORT $WEBCIT_CITADEL_IP $WEBCIT_CITADEL_PORT "" "$WEBCIT_APACHEFLAG"
164 do_start $WEBCIT_HTTPS_PORT $WEBCIT_CITADEL_IP $WEBCIT_CITADEL_PORT -s "$WEBCIT_APACHEFLAG"
165 case "$?" in
166 0) log_end_msg 0 ;;
167 1) log_end_msg 1 ;; # Old process is still running
168 *) log_end_msg 1 ;; # Failed to start
169 esac
172 # Failed to stop
173 log_end_msg 1
175 esac
176 else
177 do_start $WEBCIT_HTTP_PORT $WEBCIT_CITADEL_IP $WEBCIT_CITADEL_PORT "" "$WEBCIT_APACHEFLAG"
178 do_start $WEBCIT_HTTPS_PORT $WEBCIT_CITADEL_IP $WEBCIT_CITADEL_PORT -s "$WEBCIT_APACHEFLAG"
182 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
183 exit 3
185 esac