Fix stupid case syntax error
[onak.git] / debian / onak.init
1 #!/bin/sh
2 ### BEGIN INIT INFO
3 # Provides:          pgp-keyserver
4 # Required-Start:    $remote_fs $syslog
5 # Required-Stop:     $remote_fs $syslog
6 # Default-Start:     2 3 4 5
7 # Default-Stop:      0 1 6
8 # Short-Description: onak init script
9 # Description:       onak is a PGP keyserver with an optional persistent
10 #                    backend daemon which this script starts.
11 ### END INIT INFO
12
13 # Author: Jonathan McDowell <noodles@earth.li>
14
15 # Do NOT "set -e"
16
17 PATH=/sbin:/usr/sbin:/bin:/usr/bin
18 DESC="PGP Keyserver backend"
19 NAME=keyd
20 DAEMON=/usr/sbin/$NAME
21 DAEMON_ARGS=""
22 SCRIPTNAME=/etc/init.d/onak
23
24 # Exit if the package is not installed
25 [ -x "$DAEMON" ] || exit 0
26
27 # Load the VERBOSE setting and other rcS variables
28 . /lib/init/vars.sh
29
30 # Define LSB log_* functions.
31 # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
32 # and status_of_proc is working.
33 . /lib/lsb/init-functions
34
35 if ! grep -q -E '^use_keyd *(true|yes|1)$' /etc/onak.conf; then
36         exit 0
37 fi
38
39 case "$1" in
40   start)
41         [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
42         start-stop-daemon --start --oknodo --user onak --chuid onak \
43                 --exec $DAEMON
44         case "$?" in
45                 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
46                 1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
47         esac
48         ;;
49   stop)
50         [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
51         /usr/bin/keydctl quit
52         start-stop-daemon --stop --oknodo --user onak --exec $DAEMON
53         case "$?" in
54                 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
55                 1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
56         esac
57         ;;
58   restart|force-reload)
59         [ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME"
60         /usr/bin/keydctl quit
61         start-stop-daemon --stop --oknodo --user onak --exec $DAEMON
62         start-stop-daemon --start --oknodo --user onak --chuid onak \
63                 --exec $DAEMON
64         case "$?" in
65                 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
66                 1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
67         esac
68         ;;
69   status)
70        status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
71        ;;
72   *)
73         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
74         exit 3
75         ;;
76 esac
77
78 :