1 | #! /bin/sh
|
---|
2 |
|
---|
3 | ### BEGIN INIT INFO
|
---|
4 | # Provides: @install_name@
|
---|
5 | # Required-Start: $syslog $network
|
---|
6 | # Required-Stop: $syslog $network
|
---|
7 | # Default-Start: 2 3 4 5
|
---|
8 | # Default-Stop: 0 1 6
|
---|
9 | # Short-Description: Keep an eye on stuff
|
---|
10 | # Description: Keep an eye on stuff
|
---|
11 | ### END INIT INFO
|
---|
12 |
|
---|
13 |
|
---|
14 | # source function library
|
---|
15 | if test -f /lib/lsb/init-functions; then
|
---|
16 | . /lib/lsb/init-functions
|
---|
17 | else
|
---|
18 | echo "File /lib/lsb/init-functions not found"
|
---|
19 | exit 5
|
---|
20 | fi
|
---|
21 |
|
---|
22 | prefix="@prefix@"
|
---|
23 | exec_prefix="@exec_prefix@"
|
---|
24 | DAEMON=@sbindir@/@install_name@
|
---|
25 | NAME=@install_name@
|
---|
26 |
|
---|
27 | if test ! -f ${DAEMON}; then
|
---|
28 | log_failure_msg "Service $NAME is not installed"
|
---|
29 | exit 5
|
---|
30 | fi
|
---|
31 |
|
---|
32 | if test "x$2" != "x" && test "x$1" != "xstatus"; then
|
---|
33 | log_failure_msg "Excess arguments $@"
|
---|
34 | exit 2
|
---|
35 | fi
|
---|
36 |
|
---|
37 | log_sh_msg () {
|
---|
38 | case "$1" in
|
---|
39 | 0)
|
---|
40 | log_success_msg "Service $NAME $2"
|
---|
41 | break;
|
---|
42 | ;;
|
---|
43 | 1)
|
---|
44 | log_failure_msg "Service $NAME: Error"
|
---|
45 | break;
|
---|
46 | ;;
|
---|
47 | 4)
|
---|
48 | log_failure_msg "Service $NAME: Permission denied"
|
---|
49 | break;
|
---|
50 | ;;
|
---|
51 | 5)
|
---|
52 | log_failure_msg "Service $NAME is not installed"
|
---|
53 | break;
|
---|
54 | ;;
|
---|
55 | 7)
|
---|
56 | log_failure_msg "Service $NAME is not running"
|
---|
57 | break;
|
---|
58 | ;;
|
---|
59 | *)
|
---|
60 | log_failure_msg "Service $NAME: Error"
|
---|
61 | break;
|
---|
62 | ;;
|
---|
63 | esac
|
---|
64 | }
|
---|
65 |
|
---|
66 | log_stat_msg () {
|
---|
67 | case "$1" in
|
---|
68 | 0)
|
---|
69 | echo "Service $NAME: Running";
|
---|
70 | break;
|
---|
71 | ;;
|
---|
72 | 1)
|
---|
73 | echo "Service $NAME: Stopped and /var/run pid file exists";
|
---|
74 | break;
|
---|
75 | ;;
|
---|
76 | 3)
|
---|
77 | echo "Service $NAME: Stopped";
|
---|
78 | break;
|
---|
79 | ;;
|
---|
80 | *)
|
---|
81 | echo "Service $NAME: Status unknown";
|
---|
82 | break;
|
---|
83 | ;;
|
---|
84 | esac
|
---|
85 | }
|
---|
86 |
|
---|
87 | case "$1" in
|
---|
88 | start)
|
---|
89 | ${DAEMON} start
|
---|
90 | ERRNUM=$?
|
---|
91 | SH_ACT="started"
|
---|
92 | ;;
|
---|
93 | stop)
|
---|
94 | ${DAEMON} stop
|
---|
95 | ERRNUM=$?
|
---|
96 | if test -f @mylockfile@; then
|
---|
97 | /bin/rm -f @mylockfile@
|
---|
98 | fi
|
---|
99 | if test -S @mylockdir@/${NAME}.sock; then
|
---|
100 | /bin/rm -f @mylockdir@/${NAME}.sock
|
---|
101 | fi
|
---|
102 | SH_ACT="stopped"
|
---|
103 | ;;
|
---|
104 | restart)
|
---|
105 | ${DAEMON} restart
|
---|
106 | ERRNUM=$?
|
---|
107 | SH_ACT="restarted"
|
---|
108 | ;;
|
---|
109 | reload|force-reload)
|
---|
110 | ${DAEMON} reload
|
---|
111 | ERRNUM=$?
|
---|
112 | SH_ACT="reloaded"
|
---|
113 | ;;
|
---|
114 | status)
|
---|
115 | ${DAEMON} status
|
---|
116 | ERRNUM=$?
|
---|
117 | log_stat_msg ${ERRNUM}
|
---|
118 | exit ${ERRNUM}
|
---|
119 | ;;
|
---|
120 | *)
|
---|
121 | log_warning_msg "Usage: @install_name@ {start|stop|restart|(force-)reload|status}"
|
---|
122 | exit 2
|
---|
123 | ;;
|
---|
124 | esac
|
---|
125 |
|
---|
126 | log_sh_msg ${ERRNUM} "${SH_ACT}"
|
---|
127 | exit ${ERRNUM}
|
---|