PKGBUILDs/aur/sabnzbd/sabnzbd.init
2011-10-23 15:30:03 -04:00

44 lines
967 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 ${SABNZBD_ARGS}" -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