aboutsummaryrefslogtreecommitdiff
path: root/network/sickrage/rc.sickrage
diff options
context:
space:
mode:
authorJeremy Hansen <jebrhansen+SBo@gmail.com>2016-12-30 11:29:32 +0700
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2016-12-31 08:22:20 +0700
commit24f9d15c6da0b62f38025f432d5769616e520501 (patch)
tree4bbb83c5ebcf154d001c8cd54798e66b760147c8 /network/sickrage/rc.sickrage
parent4c78ee05e1ace38b8dfbce6a425ee09b50cb719c (diff)
network/sickrage: Added (Automatic Video Library Manager).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network/sickrage/rc.sickrage')
-rw-r--r--network/sickrage/rc.sickrage104
1 files changed, 104 insertions, 0 deletions
diff --git a/network/sickrage/rc.sickrage b/network/sickrage/rc.sickrage
new file mode 100644
index 0000000000000..89918979252a4
--- /dev/null
+++ b/network/sickrage/rc.sickrage
@@ -0,0 +1,104 @@
+#!/bin/sh
+# Start/stop/restart sickrage.
+
+# rc.sickrage created by Jeremy Brent Hansen for Slackware
+
+# Set program name in case you want to run sick{beard|rage|gear|etc}
+PROG=${PROG:-sickrage}
+
+# Source SickRage configuration
+if [ -f /etc/${PROG}.conf ]; then
+ . /etc/${PROG}.conf
+fi
+
+# Ensure all required variables are set in conf file
+# Edit conf file in /etc/sickrage.conf for any changes
+for var in USERNAME HOMEDIR DATADIR PIDFILE PORT; do
+ if [ -z "${!var}" ]; then
+ echo "/etc/${PROG}.conf is missing some or all required variables ($var)."
+ echo "Please check the file and try again."
+ exit 1
+ fi
+done
+
+# Check if the pid file exists
+check() {
+ if [ -e $PIDFILE ]; then
+ STATUS=running
+ else
+ STATUS=stopped
+ fi
+}
+
+status() {
+ if [ $STATUS == "running" ]; then
+ echo "${PROG} currently running or not shut down properly."
+ echo "PIDfile: $PIDFILE already exists."
+ elif [ $STATUS == "stopped" ]; then
+ echo "${PROG} not started."
+ echo "PIDfile: $PIDFILE does not exist."
+ else
+ echo "Status unknown."
+ fi
+}
+
+start() {
+ if [ $STATUS == "running" ]; then
+ echo "$PROG already running or not shut down properly."
+ else
+ echo -n "Starting ${PROG}: "
+ su $USERNAME -s /bin/sh -c "python ${HOMEDIR}/SickBeard.py --daemon --pidfile=${PIDFILE} --datadir=${DATADIR} --port=${PORT} &> /dev/null"
+ if (( $? == 0 )); then
+ echo "Startup Successful"
+ else
+ echo "Startup Failed. Please try running the following to see the errors."
+ echo "su $USERNAME -s /bin/sh -c \"python ${HOMEDIR}/SickBeard.py --daemon --pidfile=${PIDFILE} --datadir=${DATADIR} --port=${PORT}\""
+ fi
+ fi
+}
+
+stop() {
+ if [ $STATUS == "stopped" ]; then
+ echo "${PROG} doesn't seem to be running. Please try running"
+ echo "$0 start"
+ else
+ if [ "$EUID" -ne 0 ];then
+ echo "Please run as root"
+ exit 1
+ fi
+ PID=$(cat $PIDFILE)
+ echo -n $"Shutting down ${PROG}: "
+ curl -f http://localhost:${PORT}/home/shutdown/?pid=${PID} &> /dev/null
+ if [ $? -gt 0 ]; then
+ echo "Normal Shutdown Failed - Attempting to kill the process."
+ echo $?
+ sleep 7
+ kill -9 $PID
+ else
+ echo "Shutdown Successful"
+ fi
+ fi
+}
+
+case "$1" in
+ start)
+ check
+ start
+ ;;
+ stop)
+ check
+ stop
+ ;;
+ restart)
+ check
+ stop
+ start
+ ;;
+ status)
+ check
+ status
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|status}"
+ exit 1
+esac