Skip to content

Instantly share code, notes, and snippets.

@binford2k
Created November 8, 2013 21:43
Show Gist options
  • Save binford2k/7378147 to your computer and use it in GitHub Desktop.
Save binford2k/7378147 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# webhooks Manage webhooks service
#
# chkconfig: 2345 55 25
# description: Stupidsimple webhooks implementation.
#
# This is a pretty cruddy init script.
# source function library
#. /etc/rc.d/init.d/functions
PID=`ps ax | grep "ruby.*webhooks$" | awk '{print $1}'`
printstat()
{
if [ "$1" != "" ]
then
echo $1
else
if [ $RETVAL -eq 0 ]; then echo "OK"; else echo "FAIL"; fi
fi
}
start()
{
echo -n $"Starting webhooks: "
/usr/local/bin/webhooks
RETVAL=$?
printstat
}
stop()
{
echo -n $"Stopping webhooks: "
if [ "${PID}" == "" ]
then
printstat 'not running'
RETVAL=2
else
kill ${PID}
RETVAL=$?
sleep 3 # it would be nice if webrick didn't take so long to shut down
printstat
fi
}
status()
{
if [ "${PID}" != "" ]
then
echo $"Webhoods are running."
RETVAL=0
else
echo $"Webhoods are stopped."
RETVAL=1
fi
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=10
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment