[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)
|
---|
| 89 | ${DAEMON} start
|
---|
| 90 | ERRNUM=$?
|
---|
[279] | 91 | #
|
---|
| 92 | # The hiding kernel module
|
---|
| 93 | #
|
---|
| 94 | if [ $ERRNUM -eq 0 ]; then
|
---|
| 95 | @sh_insmod_cmd@
|
---|
| 96 | fi
|
---|
| 97 | #
|
---|
[1] | 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 | ;;
|
---|
| 131 | esac
|
---|
| 132 |
|
---|
| 133 | log_sh_msg ${ERRNUM} "${SH_ACT}"
|
---|
| 134 | exit ${ERRNUM}
|
---|