mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-12-08 23:03:46 +00:00
76 lines
1.6 KiB
Text
76 lines
1.6 KiB
Text
|
#!/bin/bash
|
||
|
|
||
|
. /etc/rc.conf
|
||
|
. /etc/rc.d/functions
|
||
|
. /etc/conf.d/sickbeard
|
||
|
|
||
|
SB_PIDFILE="/run/sickbeard/sickbeard.pid"
|
||
|
|
||
|
case "$1" in
|
||
|
start)
|
||
|
stat_busy "Starting Sick Beard"
|
||
|
|
||
|
if [ -f /run/daemons/sickbeard ]; then
|
||
|
echo "Sick Beard is already running as a daemon! If you are certain it is not, remove /run/daemons/sickbeard."
|
||
|
stat_fail
|
||
|
elif [ -f $SB_PIDFILE ]; then
|
||
|
echo "Sick Beard may already be running. If you are certain it is not, remove $SB_PIDFILE."
|
||
|
stat_fail
|
||
|
else
|
||
|
SB_ARGS+=" --pidfile $SB_PIDFILE"
|
||
|
if [ ! "$SB_USER" ]; then
|
||
|
/usr/bin/env python2 /opt/sickbeard/SickBeard.py $SB_ARGS
|
||
|
RC=$?
|
||
|
else
|
||
|
su - $SB_USER -s /bin/sh -c "/usr/bin/env python2 /opt/sickbeard/SickBeard.py $SB_ARGS"
|
||
|
RC=$?
|
||
|
fi
|
||
|
|
||
|
if [ $RC -gt 0 ]; then
|
||
|
stat_fail
|
||
|
else
|
||
|
add_daemon sickbeard
|
||
|
stat_done
|
||
|
fi
|
||
|
fi
|
||
|
;;
|
||
|
stop)
|
||
|
stat_busy "Stopping Sick Beard"
|
||
|
|
||
|
if [ ! -f $SB_PIDFILE ]; then
|
||
|
echo "The pid file is missing. Check that Sick Beard is actually running."
|
||
|
RC=1
|
||
|
else
|
||
|
read -r SB_PID < $SB_PIDFILE
|
||
|
kill $SB_PID
|
||
|
RC=$?
|
||
|
fi
|
||
|
|
||
|
if [ $RC -gt 0 ]; then
|
||
|
echo "The shutdown failed. Check that Sick Beard is actually running."
|
||
|
stat_fail
|
||
|
else
|
||
|
while [ -f $SB_PIDFILE ]; do
|
||
|
sleep 1
|
||
|
done
|
||
|
|
||
|
rm_daemon sickbeard
|
||
|
stat_done
|
||
|
fi
|
||
|
;;
|
||
|
restart)
|
||
|
"$0" stop
|
||
|
sleep 1
|
||
|
"$0" start
|
||
|
;;
|
||
|
status)
|
||
|
stat_busy "Sick Beard daemon status:";
|
||
|
ck_status $daemon_name
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
echo "usage: $0 {start|stop|restart|status}"
|
||
|
esac
|
||
|
exit 0
|
||
|
|