Skip to content

Instantly share code, notes, and snippets.

@Remz-Jay
Created August 6, 2012 21:12
Show Gist options
  • Save Remz-Jay/3278478 to your computer and use it in GitHub Desktop.
Save Remz-Jay/3278478 to your computer and use it in GitHub Desktop.
QNAP NAS /opt/etc/init.d scripts (sickbeard, couchpotato, headphones)
#! /bin/sh
### BEGIN INIT INFO
# Provides: CouchPotato
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Should-Start: $NetworkManager
# Should-Stop: $NetworkManager
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts instance of Sick Beard
# Description: starts instance of Sick Beard using start-stop-daemon
### END INIT INFO
############### EDIT ME ##################
# path to app
APP_PATH=/opt/CouchPotato
# path to python bin
DAEMON=/opt/bin/python
# Path to store PID file
PID_FILE=/var/run/CouchPotato/CouchPotato.pid
PID_PATH=`dirname $PID_FILE`
# script name
NAME=CouchPotato
# app name
DESC=CouchPotato
# user
RUN_AS=remco
# data directory
DATA_DIR=${APP_PATH}
# startup args
DAEMON_OPTS=" ${APP_PATH}/CouchPotato.py --quiet -d --nolaunch --pidfile=${PID_FILE} --datadir=${DATA_DIR}"
# --quiet -d --nolaunch
############### END EDIT ME ##################
test -x $DAEMON || exit 0
set -e
if [ ! -d $PID_PATH ]; then
mkdir -p $PID_PATH
chown $RUN_AS $PID_PATH
fi
if [ ! -d $DATA_DIR ]; then
mkdir -p $DATA_DIR
chown $RUN_AS $DATA_DIR
fi
if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
if ! kill -0 $PID > /dev/null 2>&1; then
echo "Removing stale $PID_FILE"
rm $PID_FILE
fi
fi
case "$1" in
start)
echo "Updating $DESC"
cd $APP_PATH
git reset --hard
git pull origin master
echo "Starting $DESC"
start-stop-daemon -c $RUN_AS -S -p $PID_FILE -x $DAEMON -N 1 -- $DAEMON_OPTS
;;
stop)
echo "Stopping $DESC"
start-stop-daemon -K -p $PID_FILE
;;
restart|force-reload)
echo "Restarting $DESC"
start-stop-daemon -K -p $PID_FILE
start-stop-daemon -c $RUN_AS -S -p $PID_FILE -x $DAEMON -N 1 -- $DAEMON_OPTS
;;
*)
N=/opt/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
#! /bin/sh
### BEGIN INIT INFO
# Provides: headphones
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Should-Start: $NetworkManager
# Should-Stop: $NetworkManager
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts instance of Sick Beard
# Description: starts instance of Sick Beard using start-stop-daemon
### END INIT INFO
############### EDIT ME ##################
# path to app
APP_PATH=/opt/headphones
# path to python bin
DAEMON=/opt/bin/python
# Path to store PID file
PID_FILE=/var/run/headphones/headphones.pid
PID_PATH=`dirname $PID_FILE`
# script name
NAME=headphones
# app name
DESC=Headphones
# user
RUN_AS=remco
# data directory
DATA_DIR=${APP_PATH}
# startup args
DAEMON_OPTS=" ${APP_PATH}/Headphones.py -q --daemon --pidfile=${PID_FILE} --datadir=${DATA_DIR}"
############### END EDIT ME ##################
test -x $DAEMON || exit 0
set -e
if [ ! -d $PID_PATH ]; then
mkdir -p $PID_PATH
chown $RUN_AS $PID_PATH
fi
if [ ! -d $DATA_DIR ]; then
mkdir -p $DATA_DIR
chown $RUN_AS $DATA_DIR
fi
if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
if ! kill -0 $PID > /dev/null 2>&1; then
echo "Removing stale $PID_FILE"
rm $PID_FILE
fi
fi
case "$1" in
start)
echo "Updating $DESC"
cd $APP_PATH
git reset --hard
git pull origin master
echo "Starting $DESC"
start-stop-daemon -c $RUN_AS -S -p $PID_FILE -x $DAEMON -N 1 -- $DAEMON_OPTS
;;
stop)
echo "Stopping $DESC"
start-stop-daemon -K -p $PID_FILE
;;
restart|force-reload)
echo "Restarting $DESC"
start-stop-daemon -K -p $PID_FILE
start-stop-daemon -c $RUN_AS -S -p $PID_FILE -x $DAEMON -N 1 -- $DAEMON_OPTS
;;
*)
N=/opt/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
#! /bin/sh
### BEGIN INIT INFO
# Provides: sickbeard
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Should-Start: $NetworkManager
# Should-Stop: $NetworkManager
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts instance of Sick Beard
# Description: starts instance of Sick Beard using start-stop-daemon
### END INIT INFO
############### EDIT ME ##################
# path to app
APP_PATH=/opt/Sick-Beard
# path to python bin
DAEMON=/opt/bin/python
# Path to store PID file
PID_FILE=/var/run/sickbeard/sickbeard.pid
PID_PATH=`dirname $PID_FILE`
# script name
NAME=sickbeard
# app name
DESC=SickBeard
# user
RUN_AS=remco
# data directory
DATA_DIR=${APP_PATH}
# startup args
DAEMON_OPTS=" ${APP_PATH}/SickBeard.py -q --daemon --pidfile=${PID_FILE} --datadir=${DATA_DIR}"
############### END EDIT ME ##################
test -x $DAEMON || exit 0
set -e
if [ ! -d $PID_PATH ]; then
mkdir -p $PID_PATH
chown $RUN_AS $PID_PATH
fi
if [ ! -d $DATA_DIR ]; then
mkdir -p $DATA_DIR
chown $RUN_AS $DATA_DIR
fi
if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
if ! kill -0 $PID > /dev/null 2>&1; then
echo "Removing stale $PID_FILE"
rm $PID_FILE
fi
fi
case "$1" in
start)
echo "Updating $DESC"
cd $APP_PATH
git reset --hard
git pull origin master
echo "Starting $DESC"
start-stop-daemon -c $RUN_AS -S -p $PID_FILE -x $DAEMON -N 1 -- $DAEMON_OPTS
;;
stop)
echo "Stopping $DESC"
start-stop-daemon -K -p $PID_FILE
;;
restart|force-reload)
echo "Restarting $DESC"
start-stop-daemon -K -p $PID_FILE
echo "Updating $DESC"
cd $APP_PATH
git reset --hard
git pull origin master
start-stop-daemon -c $RUN_AS -S -p $PID_FILE -x $DAEMON -N 1 -- $DAEMON_OPTS
;;
*)
N=/opt/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