1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#! /bin/sh
### BEGIN INIT INFO
# Provides: github-webhook-ofiwg
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop: 0
# Short-Description: Run the Github webhook for ofiwg
# Description:
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
[ -f /etc/default/github-webhook-ofiwg ] && . /etc/default/github-webhook-ofiwg
. /lib/lsb/init-functions
RETVAL=0
prog="/var/www/html/github-webhooks/ofiwg/verify-signed-off.rb"
desc="Github webhook listener for ofiwg"
pidfile="/var/run/github-webhook-ofiwg.pid"
do_start() {
[ -x $prog ] || exit 5
log_action_msg "Starting $desc"
pid=`ps -eadf | grep "ruby $prog" | grep -v grep | awk '{ print $2 }'`
if test -z "$pid"; then
$prog > /dev/null 2>&1 &
RETVAL=$?
else
RETVAL=1
fi
[ $RETVAL -eq 0 ] && log_success_msg
[ $RETVAL -ne 0 ] && log_failure_msg
log_end_msg $RETVAL
return $RETVAL
}
do_stop() {
[ -x $prog ] || exit 5
log_action_msg "Stopping $desc"
pid=`ps -eadf | grep "ruby $prog" | grep -v grep | awk '{ print $2 }'`
if test -n "$pid"; then
kill $pid > /dev/null 2>&1
RETVAL=$?
else
RETVAL=1
fi
[ $RETVAL -eq 0 ] && log_success_msg
[ $RETVAL -ne 0 ] && log_failure_msg
log_end_msg $RETVAL
return $RETVAL
}
do_restart() {
do_stop
sleep 1
do_start
}
case "$1" in
start)
do_start
;;
restart)
do_restart
;;
reload|force-reload)
log_action_msg "Error: argument '$1' not supported"
log_action_end_msg 7
exit 7
;;
stop)
do_stop
;;
*)
log_action_msg "Usage: $0 start|stop|restart"
log_action_end_msg 3
exit 3
;;
esac
exit $RETVAL
|