-
-
Save klynton/7403856 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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