1. #!/bin/bash
  2.  
  3. . /etc/rc.conf
  4. . /etc/rc.d/functions
  5. . /etc/conf.d/sickbeard
  6.  
  7. case ${1} in
  8. start)
  9. stat_busy "Starting Sick-Beard"
  10.  
  11. if [ -f /var/run/daemons/sickbeard ]; then
  12. echo -n "Sickbeard is already running as a daemon! If you are certain it is not running, remove /var/run/daemons/sickbeard."
  13. stat_fail
  14. else
  15. su - ${SB_USER} -c "python2 /opt/sickbeard/SickBeard.py -q -d --config ${SB_CONF} --port ${SB_PORT}" -s /bin/sh
  16. if [ ${?} -gt 0 ]; then
  17. stat_fail
  18. else
  19. add_daemon sickbeard
  20. stat_done
  21. fi
  22. fi
  23. ;;
  24. stop)
  25. stat_busy "Stopping Sick-Beard"
  26.  
  27. wget -q --delete-after http://${SB_USPW}127.0.0.1:${SB_PORT}/home/shutdown/ &> /dev/null
  28. if [ ${?} -gt 0 ]; then
  29. stat_fail
  30. else
  31. rm_daemon sickbeard
  32. stat_done
  33. fi
  34. ;;
  35. restart)
  36. "${0}" stop
  37. sleep 1
  38. "${0}" start
  39. ;;
  40. *)
  41. echo "usage: ${0} {start|stop|restart}"
  42. esac
  43. exit 0
  44.  
  45.