Merged 4.1 branch
[fprobe-ulog.git] / fprobe-initscript
diff --git a/fprobe-initscript b/fprobe-initscript
new file mode 100644 (file)
index 0000000..6cbae79
--- /dev/null
@@ -0,0 +1,71 @@
+#!/bin/sh
+#
+# chkconfig: 2345 56 25
+# description: Fprobe-ulog initscript
+#
+
+PROC=fprobe-ulog
+
+. /etc/rc.d/init.d/functions
+
+RETVAL=0
+
+pidfile=/var/run/$PROC.pid
+
+check_status() {
+    pid=`cat $pidfile 2>/dev/null`
+    #
+    # this eliminates a race condition between checking existence of pidfile
+    # and reading its value
+    #
+    [ -n "$pid" -a -d /proc/$pid ]
+}
+
+case "$1" in
+    start)
+        echo -n "starting $PROC:"
+        pid=`cat $pidfile 2>/dev/null`
+        if [ -n "$pid" ]; then
+            # check whether process really exists
+            # yes - don't try to start
+            [ -d /proc/$pid ] && action "already running" /bin/true && exit 1
+
+            # no - PID file is stale
+            rm -f $pidfile
+        fi
+
+        /sbin/fprobe-ulog -M -E 60 -T 168 -f pf2 -q 1000 -s 30 -D 250000
+       sleep 1
+
+        cmd=success
+        check_status && touch /var/lock/subsys/$PROC || cmd=failure
+        $cmd "$PROC startup"
+        echo
+        ;;
+
+    stop)
+        echo -n "shutting down $PROC: "
+        killproc $PROC
+        killproc $PROC
+        RETVAL=$?
+        echo
+        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROC
+        ;;
+
+    restart|reload)
+        $0 stop
+        $0 start
+        RETVAL=$?
+        ;;
+
+    status)
+        check_status && echo 'running' && exit 0 || \
+            echo 'not running' && exit 1
+        ;;
+
+    *)
+        echo "Usage: $0 {start|stop|restart|status}"
+        RETVAL=1
+esac
+
+exit $RETVAL