Created
September 22, 2010 08:22
-
-
Save honzakral/591353 to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
### BEGIN INIT INFO | |
# Provides: hookbox | |
# Required-Start: | |
# Required-Stop: | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 1 | |
# Short-Description: hookbox server | |
### END INIT INFO | |
set -e | |
HOOKBOX="/usr/local/bin/hookbox" | |
HOOKBOX_PID_FILE=/var/run/hookbox.pid | |
if test -e /etc/default/hookbox; then | |
. /etc/default/hookbox | |
fi | |
HOOKBOX_OPTS="--rest-secret $HOOKBOX_REST_SECRET --cbport 80 --cbhost $HOOKBOX_WEB_HOST --cbpath $HOOKBOX_WEB_PATH --cookie-identifier sessionid --log-file-errors /dev/null --log-file-access /dev/null --port $HOOKBOX_PORT" | |
export PYTHONPATH=/home/code | |
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/local/bin" | |
DAEMON_OPTS="" | |
if [ -n "$HOOKBOX_USER" ]; then | |
DAEMON_OPTS="$DAEMON_OPTS --chuid $HOOKBOX_USER" | |
fi | |
if [ -n "$HOOKBOX_GROUP" ]; then | |
DAEMON_OPTS="$DAEMON_OPTS --group $HOOKBOX_GROUP" | |
fi | |
. /lib/lsb/init-functions | |
stop_hookbox () { | |
cmd="start-stop-daemon --stop \ | |
--quiet \ | |
$* \ | |
--pidfile $HOOKBOX_PID_FILE" | |
if `$cmd`; then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
} | |
start_hookbox () { | |
cmd="start-stop-daemon --start $DAEMON_OPTS \ | |
--quiet \ | |
--oknodo \ | |
--background \ | |
--make-pidfile \ | |
$* \ | |
--pidfile $HOOKBOX_PID_FILE | |
--exec $HOOKBOX -- $HOOKBOX_OPTS" | |
if `$cmd`; then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
} | |
case "$1" in | |
start) | |
log_daemon_msg "Starting hookbox server" "hookbox" | |
start_hookbox | |
;; | |
stop) | |
log_daemon_msg "Stopping hookbox server" "hookbox" | |
stop_hookbox --oknodo | |
;; | |
reload|force-reload) | |
echo "Use start+stop" | |
;; | |
restart) | |
log_daemon_msg "Restarting hookbox task worker server" "hookbox" | |
stop_hookbox --oknodo --retry 30 | |
start_hookbox | |
;; | |
status) | |
status_of_proc -p $HOOKBOX_PID_FILE $HOOKBOX hookbox && exit 0 || exit $? | |
;; | |
*) | |
log_action_msg "Usage: /etc/init.d/hookbox {start|stop|force-reload|restart|status}" | |
exit 1 | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment