Created
February 18, 2021 16:54
-
-
Save alecs/ab6b606cc92f8d6315d54d6c454e9fae to your computer and use it in GitHub Desktop.
open-rc minimal init - template
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
#!/sbin/openrc-run | |
USER=root | |
GROUP=root | |
SERVICE="${SERVICE}" | |
DIR="/opt/${SERVICE}" | |
PDIR="/run/${SERVICE}" | |
PID_FILE="${PDIR}/${SERVICE}.pid" | |
COMMAND="" | |
CMD_ARGS="" | |
LOG_FILE="/opt/${SERVICE}/stdout.log" | |
depend() { | |
need net | |
need localmount | |
} | |
start() { | |
ebegin "Starting ${SERVICE}" | |
[[ ! -d "$PDIR" ]] && { mkdir -p $PDIR; chown nobody:nobody $PDIR; } | |
start-stop-daemon --background --start \ | |
--exec ${COMMAND} \ | |
--user ${USER:-root} \ | |
--group ${GROUP:-root} \ | |
--chdir ${DIR} \ | |
--stdout ${LOG_FILE} \ | |
--stderr ${LOG_FILE} \ | |
--pidfile ${PID_FILE} \ | |
--make-pidfile \ | |
-w 10000 -P \ | |
-- ${CMD_ARGS} | |
eend $? | |
} | |
stop() { | |
ebegin "Stopping ${SERVICE}" | |
start-stop-daemon --stop --retry 30 -P --pidfile ${PID_FILE} | |
eend $? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment