1 #! /bin/sh |
|
2 ### BEGIN INIT INFO |
|
3 # Provides: tele-watch |
|
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: watcher for dtele home directory |
|
9 # Description: tele-watch watches a list of directories |
|
10 # and enforces the dtele directory policy |
|
11 ### END INIT INFO |
|
12 |
|
13 # Author: Heiko Schlittermann <hs@schlittermann.de> |
|
14 # |
|
15 # Please remove the "Author" lines above and replace them |
|
16 # with your own name if you copy and modify this script. |
|
17 |
|
18 # Do NOT "set -e" |
|
19 |
|
20 # PATH should only include /usr/* if it runs after the mountnfs.sh script |
|
21 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin |
|
22 DESC="Tele-Watch" |
|
23 NAME=tele-watch |
|
24 DAEMON=/usr/local/sbin/$NAME |
|
25 DAEMON_ARGS="/dtele:/.dtele" |
|
26 PIDFILE=/var/run/$NAME.pid |
|
27 SCRIPTNAME=/etc/init.d/$NAME |
|
28 |
|
29 # Exit if the package is not installed |
|
30 [ -x "$DAEMON" ] || exit 0 |
|
31 |
|
32 # Read configuration variable file if it is present |
|
33 [ -r /etc/default/$NAME ] && . /etc/default/$NAME |
|
34 |
|
35 # Load the VERBOSE setting and other rcS variables |
|
36 . /lib/init/vars.sh |
|
37 |
|
38 # Define LSB log_* functions. |
|
39 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. |
|
40 . /lib/lsb/init-functions |
|
41 |
|
42 # |
|
43 # Function that starts the daemon/service |
|
44 # |
|
45 do_start() |
|
46 { |
|
47 # Return |
|
48 # 0 if daemon has been started |
|
49 # 1 if daemon was already running |
|
50 # 2 if daemon could not be started |
|
51 PID=$(pidof $NAME) && return 1 |
|
52 |
|
53 if [ ! $PID ]; then |
|
54 $DAEMON $DAEMON_ARGS || return 2 |
|
55 fi |
|
56 return 0 |
|
57 } |
|
58 |
|
59 # |
|
60 # Function that stops the daemon/service |
|
61 # |
|
62 do_stop() |
|
63 { |
|
64 # Return |
|
65 # 0 if daemon has been stopped |
|
66 # 1 if daemon was already stopped |
|
67 # 2 if daemon could not be stopped |
|
68 # other if a failure occurred |
|
69 PID=$(pidof $NAME) || return 1 |
|
70 |
|
71 $DAEMON --kill || return 2 |
|
72 return 0 |
|
73 } |
|
74 |
|
75 case "$1" in |
|
76 start) |
|
77 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" |
|
78 do_start |
|
79 case "$?" in |
|
80 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
|
81 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
|
82 esac |
|
83 ;; |
|
84 stop) |
|
85 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" |
|
86 do_stop |
|
87 case "$?" in |
|
88 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
|
89 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
|
90 esac |
|
91 ;; |
|
92 restart|force-reload) |
|
93 # |
|
94 # If the "reload" option is implemented then remove the |
|
95 # 'force-reload' alias |
|
96 # |
|
97 log_daemon_msg "Restarting $DESC" "$NAME" |
|
98 do_stop |
|
99 case "$?" in |
|
100 0|1) |
|
101 do_start |
|
102 case "$?" in |
|
103 0) log_end_msg 0 ;; |
|
104 1) log_end_msg 1 ;; # Old process is still running |
|
105 *) log_end_msg 1 ;; # Failed to start |
|
106 esac |
|
107 ;; |
|
108 *) |
|
109 # Failed to stop |
|
110 log_end_msg 1 |
|
111 ;; |
|
112 esac |
|
113 ;; |
|
114 *) |
|
115 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 |
|
116 exit 3 |
|
117 ;; |
|
118 esac |
|
119 |
|
120 : |
|