2010-09-14 04:47:33 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
. /etc/rc.conf
|
|
|
|
. /etc/rc.d/functions
|
|
|
|
. /etc/conf.d/sabnzbd
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
stat_busy "Starting SABnzbd"
|
|
|
|
|
|
|
|
if [ -f /var/run/daemons/sabnzbd ]; then
|
|
|
|
echo -n "Sabnzbd is already running as a daemon! If you are certain it is not running, remove /var/run/daemons/sabnzbd."
|
|
|
|
stat_fail
|
|
|
|
else
|
2010-12-22 20:36:48 +00:00
|
|
|
su - $SABNZBD_USER -c "python2 /opt/sabnzbd/SABnzbd.py -f $SABNZBD_CONF -s $SABNZBD_IP:$SABNZBD_PORT -d" -s /bin/sh
|
2010-09-14 04:47:33 +00:00
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
stat_fail
|
|
|
|
else
|
|
|
|
add_daemon sabnzbd
|
|
|
|
stat_done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stat_busy "Stopping SABnzbd"
|
|
|
|
|
|
|
|
curl -f "$SABNZBD_PROTOCOL://$SABNZBD_USPW$SABNZBD_IP:$SABNZBD_PORT/sabnzbd/api?mode=shutdown&apikey=$SABNZBD_KEY" &> /dev/null
|
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
stat_fail
|
|
|
|
else
|
|
|
|
rm_daemon sabnzbd
|
|
|
|
stat_done
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
$0 stop
|
|
|
|
sleep 1
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "usage: $0 {start|stop|restart}"
|
|
|
|
esac
|
|
|
|
exit 0
|