#!/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 "Sick Beard is already running as a daemon!"
stat_fail
else
su - ${SICKBEARD_USER} -c "python2 /opt/sickbeard/SickBeard.py --port ${SICKBEARD_PORT} &> /dev/null &" -s /bin/sh
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon sickbeard
stat_done
fi
fi
;;
stop)
stat_busy "Stopping Sick Beard (May take up to a minute to shutdown after this command)"
curl -f "http://localhost:${SICKBEARD_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