1 | #! /bin/sh |
---|
2 | ### BEGIN INIT INFO |
---|
3 | # Provides: debathena-lert-server |
---|
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: Athena Lert notification server |
---|
9 | # Description: The lert server sends notifications from Athena Accounts |
---|
10 | # to you, such as your account being scheduled for deletion. |
---|
11 | ### END INIT INFO |
---|
12 | |
---|
13 | # Author: Evan Broder <broder@mit.edu> |
---|
14 | |
---|
15 | # Do NOT "set -e" |
---|
16 | |
---|
17 | # PATH should only include /usr/* if it runs after the mountnfs.sh script |
---|
18 | PATH=/usr/sbin:/usr/bin:/sbin:/bin |
---|
19 | DESC="Athena Lert notification server" |
---|
20 | NAME=lertsrv |
---|
21 | DAEMON=/usr/sbin/$NAME |
---|
22 | PIDFILE=/var/run/$NAME.pid |
---|
23 | SCRIPTNAME=/etc/init.d/$NAME |
---|
24 | |
---|
25 | # Exit if the package is not installed |
---|
26 | [ -x "$DAEMON" ] || exit 0 |
---|
27 | |
---|
28 | # Load the VERBOSE setting and other rcS variables |
---|
29 | [ -f /etc/default/rcS ] && . /etc/default/rcS |
---|
30 | |
---|
31 | # Define LSB log_* functions. |
---|
32 | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. |
---|
33 | . /lib/lsb/init-functions |
---|
34 | |
---|
35 | # |
---|
36 | # Function that starts the daemon/service |
---|
37 | # |
---|
38 | do_start() |
---|
39 | { |
---|
40 | # Return |
---|
41 | # 0 if daemon has been started |
---|
42 | # 1 if daemon was already running |
---|
43 | # 2 if daemon could not be started |
---|
44 | start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --test --oknodo || return 1 |
---|
45 | start-stop-daemon --start --quiet --pidfile "$PIDFILE" \ |
---|
46 | --make-pidfile --background \ |
---|
47 | --exec "$DAEMON" || return 2 |
---|
48 | } |
---|
49 | |
---|
50 | # |
---|
51 | # Function that stops the daemon/service |
---|
52 | # |
---|
53 | do_stop() |
---|
54 | { |
---|
55 | # Return |
---|
56 | # 0 if daemon has been stopped |
---|
57 | # 1 if daemon was already stopped |
---|
58 | # 2 if daemon could not be stopped |
---|
59 | # other if a failure occurred |
---|
60 | start-stop-daemon --stop --quiet --pidfile "$PIDFILE" |
---|
61 | RETVAL="$?" |
---|
62 | [ "$RETVAL" = 2 ] && return 2 |
---|
63 | # Many daemons don't delete their pidfiles when they exit |
---|
64 | rm -f "$PIDFILE" |
---|
65 | return "$RETVAL" |
---|
66 | } |
---|
67 | |
---|
68 | case "$1" in |
---|
69 | start) |
---|
70 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" |
---|
71 | do_start |
---|
72 | case "$?" in |
---|
73 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
---|
74 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
---|
75 | esac |
---|
76 | ;; |
---|
77 | stop) |
---|
78 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" |
---|
79 | do_stop |
---|
80 | case "$?" in |
---|
81 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
---|
82 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
---|
83 | esac |
---|
84 | ;; |
---|
85 | restart|force-reload) |
---|
86 | log_daemon_msg "Restarting $DESC" "$NAME" |
---|
87 | do_stop |
---|
88 | case "$?" in |
---|
89 | 0|1) |
---|
90 | do_start |
---|
91 | case "$?" in |
---|
92 | 0) log_end_msg 0 ;; |
---|
93 | 1) log_end_msg 1 ;; # Old process is still running |
---|
94 | *) log_end_msg 1 ;; # Failed to start |
---|
95 | esac |
---|
96 | ;; |
---|
97 | *) |
---|
98 | # Failed to stop |
---|
99 | log_end_msg 1 |
---|
100 | ;; |
---|
101 | esac |
---|
102 | ;; |
---|
103 | *) |
---|
104 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 |
---|
105 | exit 3 |
---|
106 | ;; |
---|
107 | esac |
---|
108 | |
---|
109 | : |
---|