source: trunk/init/samhain.startLSB.in@ 298

Last change on this file since 298 was 279, checked in by katerina, 15 years ago

Fix for tickets #200 to #206 (kernel check, login checks, bugfixes).

File size: 2.2 KB
Line 
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
15if test -f /lib/lsb/init-functions; then
16. /lib/lsb/init-functions
17else
18 echo "File /lib/lsb/init-functions not found"
19 exit 5
20fi
21
22prefix="@prefix@"
23exec_prefix="@exec_prefix@"
24DAEMON=@sbindir@/@install_name@
25NAME=@install_name@
26
27if test ! -f ${DAEMON}; then
28 log_failure_msg "Service $NAME is not installed"
29 exit 5
30fi
31
32if test "x$2" != "x" && test "x$1" != "xstatus"; then
33 log_failure_msg "Excess arguments $@"
34 exit 2
35fi
36
37log_sh_msg () {
38case "$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 ;;
63esac
64}
65
66log_stat_msg () {
67case "$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 ;;
84esac
85}
86
87case "$1" in
88 start)
89 ${DAEMON} start
90 ERRNUM=$?
91 #
92 # The hiding kernel module
93 #
94 if [ $ERRNUM -eq 0 ]; then
95 @sh_insmod_cmd@
96 fi
97 #
98 SH_ACT="started"
99 ;;
100 stop)
101 ${DAEMON} stop
102 ERRNUM=$?
103 if test -f @mylockfile@; then
104 /bin/rm -f @mylockfile@
105 fi
106 if test -S @mylockdir@/${NAME}.sock; then
107 /bin/rm -f @mylockdir@/${NAME}.sock
108 fi
109 SH_ACT="stopped"
110 ;;
111 restart)
112 ${DAEMON} restart
113 ERRNUM=$?
114 SH_ACT="restarted"
115 ;;
116 reload|force-reload)
117 ${DAEMON} reload
118 ERRNUM=$?
119 SH_ACT="reloaded"
120 ;;
121 status)
122 ${DAEMON} status
123 ERRNUM=$?
124 log_stat_msg ${ERRNUM}
125 exit ${ERRNUM}
126 ;;
127 *)
128 log_warning_msg "Usage: @install_name@ {start|stop|restart|(force-)reload|status}"
129 exit 2
130 ;;
131esac
132
133log_sh_msg ${ERRNUM} "${SH_ACT}"
134exit ${ERRNUM}
Note: See TracBrowser for help on using the repository browser.