Last active
October 11, 2015 18:11
-
-
Save ndelitski/9dee68735ea391b68aa8 to your computer and use it in GitHub Desktop.
init.d script template
This file contains hidden or 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: convoy | |
# Required-Start: $local_fs $network $named $time $syslog | |
# Required-Stop: $local_fs $network $named $time $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Description: Rancher Convoy docker volume plugin | |
### END INIT INFO | |
DAEMON=/usr/local/bin/convoy | |
DAEMON_NAME=convoy | |
# Add any command line options for your daemon here | |
DAEMON_OPTS="--drivers ebs" | |
# This next line determines what user the script runs as. | |
# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python. | |
DAEMON_USER=root | |
PIDFILE=/var/run/${DAEMON_NAME}.pid | |
LOGFILE=/var/log/${DAEMON_NAME}.log | |
. /lib/lsb/init-functions | |
start () { | |
log_daemon_msg "Starting system $DAEMON_NAME daemon" | |
start-stop-daemon --start --background \ | |
--pidfile $PIDFILE --make-pidfile \ | |
--user $DAEMON_USER --chuid $DAEMON_USER \ | |
--startas /bin/bash -- -c "$DAEMON $DAEMON_OPTS > $LOGFILE 2>&1" | |
log_end_msg $? | |
} | |
stop () { | |
log_daemon_msg "Stopping system $DAEMON_NAME daemon" | |
start-stop-daemon --stop --pidfile $PIDFILE --retry 10 | |
log_end_msg $? | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $? | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|status}" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LSB init scripts