[1] | 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)
|
---|
[321] | 89 | #
|
---|
| 90 | # Preloaded kernel module
|
---|
| 91 | #
|
---|
| 92 | @sh_insmod_pre@
|
---|
| 93 | #
|
---|
[1] | 94 | ${DAEMON} start
|
---|
| 95 | ERRNUM=$?
|
---|
[279] | 96 | #
|
---|
| 97 | # The hiding kernel module
|
---|
| 98 | #
|
---|
| 99 | if [ $ERRNUM -eq 0 ]; then
|
---|
| 100 | @sh_insmod_cmd@
|
---|
| 101 | fi
|
---|
| 102 | #
|
---|
[1] | 103 | SH_ACT="started"
|
---|
| 104 | ;;
|
---|
| 105 | stop)
|
---|
| 106 | ${DAEMON} stop
|
---|
| 107 | ERRNUM=$?
|
---|
| 108 | if test -f @mylockfile@; then
|
---|
| 109 | /bin/rm -f @mylockfile@
|
---|
| 110 | fi
|
---|
| 111 | if test -S @mylockdir@/${NAME}.sock; then
|
---|
| 112 | /bin/rm -f @mylockdir@/${NAME}.sock
|
---|
| 113 | fi
|
---|
| 114 | SH_ACT="stopped"
|
---|
| 115 | ;;
|
---|
| 116 | restart)
|
---|
| 117 | ${DAEMON} restart
|
---|
| 118 | ERRNUM=$?
|
---|
| 119 | SH_ACT="restarted"
|
---|
| 120 | ;;
|
---|
| 121 | reload|force-reload)
|
---|
| 122 | ${DAEMON} reload
|
---|
| 123 | ERRNUM=$?
|
---|
| 124 | SH_ACT="reloaded"
|
---|
| 125 | ;;
|
---|
| 126 | status)
|
---|
| 127 | ${DAEMON} status
|
---|
| 128 | ERRNUM=$?
|
---|
| 129 | log_stat_msg ${ERRNUM}
|
---|
| 130 | exit ${ERRNUM}
|
---|
| 131 | ;;
|
---|
| 132 | *)
|
---|
| 133 | log_warning_msg "Usage: @install_name@ {start|stop|restart|(force-)reload|status}"
|
---|
| 134 | exit 2
|
---|
| 135 | ;;
|
---|
| 136 | esac
|
---|
| 137 |
|
---|
| 138 | log_sh_msg ${ERRNUM} "${SH_ACT}"
|
---|
| 139 | exit ${ERRNUM}
|
---|