PKGBUILDs/aur/sabnzbd/sabnzbd.init

44 lines
967 B
Text
Raw Normal View History

2011-05-17 22:02:46 +00:00
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/sabnzbd
2011-10-23 19:30:03 +00:00
case "${1}" in
2011-05-17 22:02:46 +00:00
start)
stat_busy "Starting SABnzbd"
2011-10-23 19:30:03 +00:00
2011-05-17 22:02:46 +00:00
if [ -f /var/run/daemons/sabnzbd ]; then
2011-10-23 19:30:03 +00:00
echo -n "Sabnzbd is already running as a daemon! If you are certain it is not running, remove /var/run/daemons/sabnzbd."
stat_fail
2011-05-17 22:02:46 +00:00
else
2011-10-23 19:30:03 +00:00
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
2011-05-17 22:02:46 +00:00
fi
;;
stop)
stat_busy "Stopping SABnzbd"
2011-10-23 19:30:03 +00:00
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
2011-05-17 22:02:46 +00:00
else
2011-10-23 19:30:03 +00:00
rm_daemon sabnzbd
stat_done
2011-05-17 22:02:46 +00:00
fi
;;
restart)
2011-10-23 19:30:03 +00:00
"${0}" stop
2011-05-17 22:02:46 +00:00
sleep 1
2011-10-23 19:30:03 +00:00
"${0}" start
2011-05-17 22:02:46 +00:00
;;
*)
2011-10-23 19:30:03 +00:00
echo "usage: ${0} {start|stop|restart}"
2011-05-17 22:02:46 +00:00
esac
exit 0