From 7c45f632665ce1168cc87e3486128a65f3b5cc33 Mon Sep 17 00:00:00 2001 From: Josh Enders Date: Sat, 31 Jan 2015 21:38:41 -0800 Subject: [PATCH] Updates init script --- Autostart-on-Debian.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Autostart-on-Debian.md b/Autostart-on-Debian.md index c799874..c2e09a3 100644 --- a/Autostart-on-Debian.md +++ b/Autostart-on-Debian.md @@ -1,6 +1,6 @@ # Autostart on Debian using init.d script -The instructions for Ubuntu/Debian did not seem to work for Debian very well, and the pid got lost whenever Sonarr was restarted via the web-ui, so I've included a working script here init.d script here. +The instructions for Ubuntu/Debian did not seem to work for Debian very well, and the pid got lost whenever Sonarr was restarted via the web-ui, so I've included a working script here init.d script here. You'll need to have already created an nzbdrone user. **Create and edit the nzbdrone init.d script** @@ -47,14 +47,18 @@ NZBDRONE_PID=`ps auxf | grep $EXENAME | grep -v grep | awk '{print $2}'` test -x $DAEMON || { echo "$DAEMON must be executable."; exit 1; } set -e - + +if [ ! -e ${PID_PATH} ]; then + mkdir ${PID_PATH} +fi + echo $NZBDRONE_PID > $PID_FILE case "$1" in start) if [ -z "${NZBDRONE_PID}" ]; then echo "Starting $DESC" - rm -rf $PID_PATH || return 1 + rm -rf ${PID_PATH:?} || return 1 install -d --mode=0755 -o $RUN_AS $PID_PATH || return 1 start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS $EXENAME else