#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/sickbeard
case ${1} in
start)
stat_busy "Starting Sick-Beard"
if [ -f /var/run/daemons/sickbeard ]; then
echo -n "Sickbeard is already running as a daemon! If you are certain it is not running, remove /var/run/daemons/sickbeard."
stat_fail
else
su - ${SB_USER} -c "python2 /opt/sickbeard/SickBeard.py -q -d --config ${SB_CONF} --port ${SB_PORT}" -s /bin/sh
if [ ${?} -gt 0 ]; then
stat_fail
else
add_daemon sickbeard
stat_done
fi
fi
;;
stop)
stat_busy "Stopping Sick-Beard"
wget -q --delete-after http://${SB_USPW}127.0.0.1:${SB_PORT}/home/shutdown/ &> /dev/null
if [ ${?} -gt 0 ]; then
stat_fail
else
rm_daemon sickbeard
stat_done
fi
;;
restart)
"${0}" stop
sleep 1
"${0}" start
;;
*)
echo "usage: ${0} {start|stop|restart}"
esac
exit 0