]> mj.ucw.cz Git - ursary.git/blob - debian-init
Reconfigured for new burrow ... still lots of tmp hacks there
[ursary.git] / debian-init
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides:          ursaryd
4 # Required-Start:    $local_fs $remote_fs pulseaudio
5 # Required-Stop:     $local_fs $remote_fs
6 # Default-Start:     2 3 4 5
7 # Default-Stop:      0 1 6
8 # Short-Description: Ursary control panel daemon
9 ### END INIT INFO
10
11 # Authors: Martin Mares <mj@ucw.cz>
12
13 # Do NOT "set -e"
14
15 # PATH should only include /usr/* if it runs after the mountnfs.sh script
16 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/opt/sbin:/opt/bin
17 DESC="Ursary control panel daemon"
18 NAME=ursaryd
19 DAEMON=/usr/local/sbin/ursaryd
20 DAEMON_ARGS=""
21 PIDFILE=/run/ursaryd.pid
22 SCRIPTNAME=/etc/init.d/$NAME
23
24 # Exit if the package is not installed
25 [ -x "$DAEMON" ] || exit 0
26
27 # Read configuration variable file if it is present
28 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
29
30 # Load the VERBOSE setting and other rcS variables
31 . /lib/init/vars.sh
32
33 # Define LSB log_* functions.
34 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
35 . /lib/lsb/init-functions
36
37 do_start()
38 {
39         ulimit -c unlimited
40         ucw-daemon-control --start --pid-file $PIDFILE -- $DAEMON $DAEMON_ARGS
41 }
42
43 do_stop()
44 {
45         ucw-daemon-control --stop --pid-file $PIDFILE
46 }
47
48 do_reload()
49 {
50         ucw-daemon-control --reload --pid-file $PIDFILE
51 }
52
53 do_status()
54 {
55         ucw-daemon-control --check --pid-file $PIDFILE
56 }
57
58 case "$1" in
59   start)
60         [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
61         do_start
62         case "$?" in
63           0)    [ "$VERBOSE" != no ] && log_end_msg 0 ;;
64           100)  [ "$VERBOSE" != no ] && log_progress_msg "already running" && log_end_msg 0 ;;
65           103)  [ "$VERBOSE" != no ] && log_progress_msg "found dead, restarting" && log_end_msg 0 ;;
66           *)    [ "$VERBOSE" != no ] && log_end_msg 1 ;;
67         esac
68         ;;
69   stop)
70         [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
71         do_stop
72         case "$?" in
73           0)    [ "$VERBOSE" != no ] && log_end_msg 0 ;;
74           100)  [ "$VERBOSE" != no ] && log_progress_msg "already stopped" && log_end_msg 0 ;;
75           103)  [ "$VERBOSE" != no ] && log_progress_msg "already dead" && log_end_msg 0 ;;
76           *)    [ "$VERBOSE" != no ] && log_end_msg 1 ;;
77         esac
78         ;;
79   reload|force-reload)
80         log_daemon_msg "Reloading $DESC" "$NAME"
81         do_reload
82         case "$?" in
83           0)            log_end_msg 0 ;;
84           101|103)      log_progress_msg "is not running" && log_end_msg 1 ;;
85           *)            log_end_msg 1 ;;
86         esac
87         ;;
88   restart)
89         log_daemon_msg "Restarting $DESC" "$NAME"
90         do_stop
91         case "$?" in
92           0|100|103)
93                 do_start
94                 case "$?" in
95                   0|100)        log_end_msg 0 ;;
96                   103)          log_progress_msg "was found dead" && log_end_msg 0 ;;
97                   *)            log_end_msg 1 ;;
98                 esac
99                 ;;
100           *)
101                 log_end_msg 1
102                 ;;
103         esac
104         ;;
105   status)
106         do_status
107         case "$?" in
108           0)    exit 0 ;;
109           101)  exit 3 ;;
110           103)  exit 1 ;;
111           *)    exit 4 ;;
112         esac
113         ;;
114   *)
115         echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2
116         exit 3
117         ;;
118 esac
119
120 :