Skip to content

Instantly share code, notes, and snippets.

@Toilal
Last active October 11, 2017 07:31
Show Gist options
  • Save Toilal/8096586 to your computer and use it in GitHub Desktop.
Save Toilal/8096586 to your computer and use it in GitHub Desktop.
init.d script for Pootle
#! /bin/sh -e
### BEGIN INIT INFO
# Provides: pootle
# Required-Start: $apache2
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Pootle
# Description: Get your community translating your software into their languages.
### END INIT INFO
DAEMON_DIR="/opt/pyenv/versions/2.7.6-pootle/bin/" # Program binary location
DAEMON_BIN="pootle" # Program binary filename
DAEMON_OPT="start" # Program argument
DAEMON_USER="pootle" # User to run
DAEMON_CWD="/home/pootle" # Working directory
test -x $DAEMON_DIR$DAEMON_BIN || exit 0
. /lib/lsb/init-functions
d_start () {
log_daemon_msg "Starting $DAEMON_BIN Daemon"
echo start-stop-daemon --background --name $DAEMON_BIN --start --chdir $DAEMON_CWD --chuid $DAEMON_USER --exec $DAEMON_DIR$DAEMON_BIN -- $DAEMON_OPT
start-stop-daemon --background --name $DAEMON_BIN --start --chdir $DAEMON_CWD --chuid $DAEMON_USER --exec $DAEMON_DIR$DAEMON_BIN -- $DAEMON_OPT
log_end_msg $?
}
d_stop () {
log_daemon_msg "Stopping $DAEMON_BIN Daemon"
start-stop-daemon --name $DAEMON_BIN --stop --retry 5 --name $DAEMON_BIN
log_end_msg $?
}
case "$1" in
start|stop)
d_${1}
;;
restart|reload|force-reload)
d_stop
d_start
;;
force-stop)
d_stop
killall -q $DAEMON_BIN || true
sleep 2
killall -q -9 $DAEMON_BIN || true
;;
status)
status_of_proc "$DAEMON_BIN" "$DAEMON_BIN" && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$DAEMON_BIN {start|stop|force-stop|restart|reload|force-reload|status}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment