Fix memory bugs.
[fprobe-ulog.git] / fprobe-initscript
1 #!/bin/sh
2 #
3 # chkconfig: 2345 56 25
4 # description: Fprobe-ulog initscript
5 #
6
7 PROC=fprobe-ulog
8
9 . /etc/rc.d/init.d/functions
10
11 RETVAL=0
12
13 pidfile=/var/run/$PROC.pid
14
15 check_status() {
16     pid=`cat $pidfile 2>/dev/null`
17     #
18     # this eliminates a race condition between checking existence of pidfile
19     # and reading its value
20     #
21     [ -n "$pid" -a -d /proc/$pid ]
22 }
23
24 case "$1" in
25     start)
26         echo -n "starting $PROC:"
27         pid=`cat $pidfile 2>/dev/null`
28         if [ -n "$pid" ]; then
29             # check whether process really exists
30             # yes - don't try to start
31             [ -d /proc/$pid ] && action "already running" /bin/true && exit 1
32
33             # no - PID file is stale
34             rm -f $pidfile
35         fi
36
37         /sbin/fprobe-ulog -M -e 3600 -d 3600 -E 60 -T 168 -f pf2 -q 1000 -s 30 -D 250000
38         sleep 1
39
40         cmd=success
41         check_status && touch /var/lock/subsys/$PROC || cmd=failure
42         $cmd "$PROC startup"
43         echo
44         ;;
45
46     stop)
47         echo -n "shutting down $PROC: "
48         killproc $PROC
49         killproc $PROC
50         RETVAL=$?
51         echo
52         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROC
53         ;;
54
55     restart|reload)
56         $0 stop
57         $0 start
58         RETVAL=$?
59         ;;
60
61     status)
62         check_status && echo 'running' && exit 0 || \
63             echo 'not running' && exit 1
64         ;;
65
66     condrestart)
67         if check_status; then
68             $0 restart
69             RETVAL=$?
70         else
71             RETVAL=0
72         fi
73         ;;
74
75     *)
76         echo "Usage: $0 {start|stop|restart|status}"
77         RETVAL=1
78 esac
79
80 exit $RETVAL