Rev | Line | |
---|
[1] | 1 | #! /bin/sh -
|
---|
| 2 | #
|
---|
| 3 | # initialization/shutdown script for @install_name@ package
|
---|
| 4 |
|
---|
| 5 | prefix="@prefix@"
|
---|
| 6 | exec_prefix="@exec_prefix@"
|
---|
| 7 |
|
---|
| 8 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
---|
| 9 | DAEMON=@sbindir@/@install_name@
|
---|
| 10 | NAME=@install_name@
|
---|
| 11 | pidfile=@mylockfile@
|
---|
| 12 |
|
---|
| 13 | test -f $DAEMON || exit 0
|
---|
| 14 |
|
---|
| 15 | safe_pidof () {
|
---|
| 16 | pidval=0
|
---|
| 17 | if [ -f $pidfile ] ; then
|
---|
| 18 | pidval=`cat $pidfile | awk '{ print $1 }'`
|
---|
| 19 | echo "${pidval}" | grep ['[^0123456789]'] >/dev/null 2>&1 && pidval=0
|
---|
| 20 | fi
|
---|
| 21 | echo $pidval
|
---|
| 22 | if [ x"$pidval" = x0 ] ; then
|
---|
| 23 | return 1
|
---|
| 24 | else
|
---|
| 25 | return 0
|
---|
| 26 | fi
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | log_stat_msg () {
|
---|
| 30 | case "$1" in
|
---|
| 31 | 0)
|
---|
| 32 | echo "Service $NAME: Running";
|
---|
| 33 | break;
|
---|
| 34 | ;;
|
---|
| 35 | 1)
|
---|
| 36 | echo "Service $NAME: Stopped and @mylockfile@ pid file exists";
|
---|
| 37 | break;
|
---|
| 38 | ;;
|
---|
| 39 | 3)
|
---|
| 40 | echo "Service $NAME: Stopped";
|
---|
| 41 | break;
|
---|
| 42 | ;;
|
---|
| 43 | *)
|
---|
| 44 | echo "Service $NAME: Status unknown";
|
---|
| 45 | break;
|
---|
| 46 | ;;
|
---|
| 47 | esac
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | case "$1" in
|
---|
| 51 | start)
|
---|
| 52 | #
|
---|
| 53 | # Remove a stale lockfile, if found
|
---|
| 54 | #
|
---|
| 55 | if test -f @mylockfile@; then
|
---|
| 56 | rm -f @mylockfile@
|
---|
| 57 | fi
|
---|
| 58 | /bin/rm -f @mylockdir@/${NAME}.sock
|
---|
| 59 | $DAEMON -D && echo -n " $NAME"
|
---|
| 60 | ;;
|
---|
| 61 | stop)
|
---|
| 62 | PID=`safe_pidof`
|
---|
| 63 | if test "x$PID" != x0
|
---|
| 64 | then
|
---|
| 65 | kill $PID && echo -n " $NAME"
|
---|
| 66 | fi
|
---|
| 67 | ;;
|
---|
| 68 | reload|force-reload)
|
---|
| 69 | PID=`safe_pidof`
|
---|
| 70 | if test "x$PID" != x0
|
---|
| 71 | then
|
---|
| 72 | echo " Reloading $NAME configuration file."
|
---|
| 73 | kill -s HUP $PID && echo -n " $NAME"
|
---|
| 74 | else
|
---|
| 75 | echo " Cannot determine PID of process $NAME."
|
---|
| 76 | exit 1
|
---|
| 77 | fi
|
---|
| 78 | ;;
|
---|
| 79 | restart)
|
---|
| 80 | $0 stop
|
---|
| 81 | sleep 3
|
---|
| 82 | $0 start
|
---|
| 83 | ;;
|
---|
| 84 | status)
|
---|
| 85 | $DAEMON status
|
---|
| 86 | ERRNUM=$?
|
---|
| 87 | log_stat_msg ${ERRNUM}
|
---|
| 88 | exit ${ERRNUM}
|
---|
| 89 | ;;
|
---|
| 90 | *)
|
---|
| 91 | echo " Usage: $0 {start|stop|restart|reload|force-reload}" >&2
|
---|
| 92 | exit 1
|
---|
| 93 | ;;
|
---|
| 94 | esac
|
---|
| 95 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.