#! /bin/bash # github-webhook init script # ### BEGIN INIT INFO # Provides: github-webhook # Required-Start: $remote_fs # Required-Stop: $remote_fs # Should-Start: $network # Should-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: rebuild daemon # Description: daemon providing rebuild system # for Debian packages ### END INIT INFO PATH=/home/vinaigrette/scripts/webhooks/venv/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/home/vinaitrette/webhooks/server.py NAME=github-webhook DESC="GitHub WebHook daemon" GWH_UID=pbuilder GWH_GROUP=pbuilder GWH_CHROOT=/home/vinaigrette/webhooks LOGDIR=/var/log/$NAME LOGFILE=$NAME.log test -x $DAEMON || exit 0 # Include github-webhook defaults if available if [ -f /etc/default/github-webhook ] ; then . /etc/default/github-webhook fi . /lib/lsb/init-functions set -e function do_start { mkdir -p $LOGDIR chown -R $GWH_UID:$GWH_GROUP $LOGDIR start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ --chuid $GWH_UID:$GWH_GROUP --chdir $GWH_CHROOT \ --background --make-pidfile --startas /bin/bash -- -c "exec python $DAEMON >> $LOGDIR/$LOGFILE 2>&1" } function do_stop { start-stop-daemon --stop --quiet --oknodo --retry 120 --pidfile /var/run/$NAME.pid } case "$1" in start) log_daemon_msg "Starting $DESC" "$NAME" do_start log_end_msg $? ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" do_stop log_end_msg $? ;; restart) log_daemon_msg "Restarting $DESC" "$NAME" do_stop sleep 1 do_start log_end_msg $? ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart}" >&2 exit 1 ;; esac exit 0