source: trunk/init/samhain.startFreeBSD.in@ 1

Last change on this file since 1 was 1, checked in by katerina, 19 years ago

Initial import

File size: 1.7 KB
RevLine 
[1]1#! /bin/sh -
2#
3# initialization/shutdown script for @install_name@ package
4
5prefix="@prefix@"
6exec_prefix="@exec_prefix@"
7
8PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
9DAEMON=@sbindir@/@install_name@
10NAME=@install_name@
11pidfile=@mylockfile@
12
13test -f $DAEMON || exit 0
14
15safe_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
29log_stat_msg () {
30case "$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 ;;
47esac
48}
49
50case "$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 ;;
94esac
95
Note: See TracBrowser for help on using the repository browser.