Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bluepill init script
#!/bin/sh
### BEGIN INIT INFO
# Provides: bluepill
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: bluepill daemon, providing process monitoring
# Description: bluepill is a monitoring tool. More info at http://github.com/arya/bluepill.
### END INIT INFO
# Check for missing binaries
BLUEPILL_BIN=/opt/ruby-1.9.2-p290/bin/bluepill
test -x $BLUEPILL_BIN || { echo "$BLUEPILL_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
bluepill () {
CONFIG=/etc/bluepill/$2.conf
if [ -n "$2" ]; then
if [ -e $CONFIG ]; then
if [ $1 = "load" ]; then
$BLUEPILL_BIN load $CONFIG
else
$BLUEPILL_BIN $2 $1
fi
else
echo "$CONFIG not found."
exit 1
fi
else
for CONFIG in /etc/bluepill/*.conf; do
NAME=`basename $CONFIG .conf`
echo "== $NAME =="
if [ $1 = "load" ]; then
$BLUEPILL_BIN load $CONFIG
else
$BLUEPILL_BIN $NAME $1
fi
done
fi
}
case $1 in
start)
echo "Starting bluepill:"
bluepill load $2
;;
stop)
echo "Shutting down bluepill:"
bluepill quit $2
;;
status)
bluepill status $2
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
;;
*)
## If no parameters are given, print which are avaiable.
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment