Created
November 16, 2017 23:56
-
-
Save iturgeon/e0a34e23b6320a6ea1572f1c9147920e to your computer and use it in GitHub Desktop.
Udoit init.d script
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 | |
# Installation | |
# 1. Move this script to /etc/init.d/udoitworker | |
# 2. chmod +x /etc/init.d/udoitworker | |
# 3. set DAEMON - full path to php executable (hint: `which php`) | |
# 4. set DAEMON_OPTS - full path to the worker php script and any options you desire | |
# | |
# Run on boot | |
# - openRC: `rc-update add udoitworker default` | |
# - ubuntu: `update-rc.d udoitworker defaults && update-rc.d udotiworker enable` | |
# | |
# Starting and stopping | |
# - Start: `service udoitworker start` or `/etc/init.d/udoitworker start` or `rc-service udoitworker start` | |
# - Stop: `service udoitworker stop` or `/etc/init.d/udoitworker stop` or `rc-service udoitworker start` | |
# UPDATE this with the path to your system's php executable | |
DAEMON="/path/to//php" | |
# UPDATE this with the path to the UDOIT worker | |
DAEMON_OPTS="/var/www/udoit/lib/worker.php" | |
NAME=udoitworker | |
DESC="Daemon for the UDOIT background worker" | |
PIDFILE="/var/run/${NAME}.pid" | |
LOGFILE="/var/log/${NAME}.log" | |
START_OPTS="--start --background --make-pidfile --pidfile ${PIDFILE} --exec ${DAEMON} ${DAEMON_OPTS} -1 ${LOGFILE} -2 ${LOGFILE}" | |
STOP_OPTS="--stop --pidfile ${PIDFILE}" | |
test -x $DAEMON || exit 0 | |
set -e | |
case "$1" in | |
start) | |
echo -n "Starting ${DESC}: " | |
start-stop-daemon $START_OPTS >> $LOGFILE | |
echo "$NAME." | |
;; | |
stop) | |
echo -n "Stopping $DESC: " | |
start-stop-daemon $STOP_OPTS | |
echo "$NAME." | |
rm -f $PIDFILE | |
;; | |
restart|force-reload) | |
echo -n "Restarting $DESC: " | |
start-stop-daemon $STOP_OPTS | |
sleep 1 | |
start-stop-daemon $START_OPTS >> $LOGFILE | |
echo "$NAME." | |
;; | |
*) | |
N=/etc/init.d/$NAME | |
echo "Usage: $N {start|stop|restart|force-reload}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment