Snorby init script fuer Debian

#! /bin/bash
#
### BEGIN INIT INFO

# Provides: snorby
# Required-Start: $remote_fs $syslog $mysql $snortbarn
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Snorby

### END INIT INFO

. /lib/init/vars.sh
. /lib/lsb/init-functions

DIR="/usr/local/snorby"
DAEMON="/usr/local/bin/bundle"
DAEMON_ARGS="exec rails server -e production"
NAME="snorby"
PIDFILE="/var/run/$NAME.pid"

do_start() {
        log_daemon_msg "Starting" "$NAME"
	if kill -0 $(cat $PIDFILE) &>/dev/null
	then
		log_end_msg 1
	else
        	start-stop-daemon --start -b -m --quiet -d $DIR --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS &>/dev/null && log_end_msg 0 || log_end_msg 1
	fi
}
 
do_stop() {
	log_daemon_msg "Stopping" "$NAME"
	start-stop-daemon --stop --quiet -d $DIR -s KILL --pidfile $PIDFILE &>/dev/null && log_end_msg 0 || log_end_msg 1
}
 
case "$1" in
  start)
        do_start
 ;;
  stop)
        do_stop
 ;;
  restart)
        do_stop
        do_start
 ;;
 *)
      	echo "Usage: $0 {start|stop|restart}" >&2
    	exit 3
 ;;
esac

exit 0

Schreibe einen Kommentar