PKGBUILDs/aur/sabnzbd/sabnzbd.init
2011-05-17 18:02:46 -04:00

43 lines
968 B
Bash

#!/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
su - $SABNZBD_USER -c "python2 /opt/sabnzbd/SABnzbd.py -f $SABNZBD_CONF -s $SABNZBD_IP:$SABNZBD_PORT -d" -s /bin/sh
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