#!/bin/sh # # ---------------------------------------------------------------------- # /etc/init.d/ds200: start the syslog named pipe listener. # ---------------------------------------------------------------------- # On Debian, install this with something like: # # update-rc.d ds200 defaults 09 91 # # This assumes that sysklogd installs itself with 10 90. # ---------------------------------------------------------------------- PATH=/bin:/usr/bin:/sbin:/usr/sbin pidfile=/var/run/ds200/pid binpath=/your/path/ds200/parse_fifo test -x $binpath || exit 0 create_fifo() { if [ ! -e /var/run/ds200/fifo ]; then mknod /var/run/ds200/fifo p fi } running() { if [ ! -f $pidfile ]; then return 1 fi pid=`cat $pidfile` if [ -z "$pid" ]; then return 1 fi # Check that there is such a process. if [ ! -d "/proc/$pid" ]; then return 1 fi # Check that the first line is the perl interpreter: cmd=`cat /proc/$pid/cmdline | tr "\000" "\n" | head -1` if [ "$cmd" != "/usr/bin/perl" ]; then return 1 fi # Check that the last line is the script we run: cmd=`cat /proc/$pid/cmdline | tr "\000" "\n" | tail -1` if [ "$cmd" != "$binpath" ]; then return 1 fi return 0 } case "$1" in start) echo -n "Starting DS200 listener... " if running; then echo "Already running." else create_fifo start-stop-daemon \ --start \ --quiet \ --background \ --make-pidfile \ --pidfile $pidfile \ --exec $binpath \ --name parse_fifo echo "Done." fi ;; stop) echo -n "Stopping DS200 listeners... " start-stop-daemon \ --stop \ --quiet \ --pidfile $pidfile \ --name parse_fifo echo "Done." ;; restart) echo -n "Stopping DS200 listeners... " start-stop-daemon \ --stop \ --quiet \ --pidfile $pidfile \ --name parse_fifo echo "Done." sleep 1 echo -n "Starting DS200 listeners... " create_fifo start-stop-daemon \ --start \ --quiet \ --background \ --make-pidfile \ --pidfile $pidfile \ --exec $binpath \ --name parse_fifo echo "Done." ;; reload|force-reload|reload-or-restart) start-stop-daemon \ --stop \ --quiet \ --pidfile $pidfile \ --name parse_fifo sleep 1 create_fifo start-stop-daemon \ --start \ --quiet \ --background \ --make-pidfile \ --pidfile $pidfile \ --exec $binpath \ --name parse_fifo ;; *) echo "Usage: /etc/init.d/ds200 {start|stop|reload|restart}" exit 1 esac exit 0