Linux start/stop script for sabnzbd and episode butler
Posted: April 17th, 2009, 11:03 am
Hey guys, I put this together from information in the sabnzbd online manual and from episode butler forum threads... figured I would share. This script will both start and stop sabnzbd and episode butler properly during system startup/shutdown/reboot. I found that without properly shutting down sab and episode butler, their data can become damaged.
A couple of necessary steps:
1. The SABnzbd source has been moved to: /usr/share/SABnzbd
2. The Episode Butler source has been moved to: /home/username/.episodebutler
3. Set the variables: be sure to properly edit the variables in these scripts to match your setup (username, home dir, ip address:port, login, password, etc)
Once these things are in place, save the script to /etc/init.d/sabnzbd.sh
Make the script executable:
Use update-rc.d to add the script to the startup/shutdown/reboot run levels (I have tested this on Ubuntu 8.10 and found that these run levels work well. It may vary by linux distro)
That should do it, sab and episode butler should now start and stop automatically on startup/shutdown/reboot. You can manually start/stop by using these commands:
and
This is for Pre SABnzbd 0.4.9 (No API Key Required)
This is for SABnzbd 0.4.9 or later (API Key Required)
Good luck!
tret
A couple of necessary steps:
1. The SABnzbd source has been moved to: /usr/share/SABnzbd
2. The Episode Butler source has been moved to: /home/username/.episodebutler
3. Set the variables: be sure to properly edit the variables in these scripts to match your setup (username, home dir, ip address:port, login, password, etc)
Once these things are in place, save the script to /etc/init.d/sabnzbd.sh
Make the script executable:
Code: Select all
sudo chmod +x /etc/init.d/sabnzbd.sh
Code: Select all
sudo update-rc.d sabnzbd.sh start 30 2 3 4 5 . stop 14 0 1 6 .
Code: Select all
/etc/init.d/sabnzbd.sh start
Code: Select all
/etc/init.d/sabnzbd.sh stop
This is for Pre SABnzbd 0.4.9 (No API Key Required)
Code: Select all
#! /bin/sh
### BEGIN INIT INFO
# Provides: sabnzbd, episode butler
# Short-Description: start/stop sabnzbd and episode butler web interface
### END INIT INFO
USER="username"
HOME="/home/username"
SAB_IP="192.168.1.2:8081"
SAB_USER="login"
SAB_PASS="password"
BUTLER_IP="192.168.1.2:8082"
BUTLER_USER="login"
BUTLER_PASS="password"
case "$1" in
start)
echo "Starting SABnzbd."
/usr/bin/sudo -u $USER -H /usr/share/SABnzbd/SABnzbd.py -d -f $HOME/.sabnzbd/sabnzbd.ini
sleep 2
echo "Starting Episode Butler."
/usr/bin/sudo -u $USER -H $HOME/.episodebutler/./episodebutler &
;;
stop)
echo "Shutting down SABnzbd."
/usr/bin/wget -q --delete-after "http://$SAB_IP/sabnzbd/api?mode=shutdown&ma_username=$SAB_USER&ma_password=$SAB_PASS"
echo "Shutting down Episode Butler."
/usr/bin/wget -q --delete-after --post-data=username=$BUTLER_USER\&password=$BUTLER_PASS "http://$BUTLER_IP/quit"
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0
Code: Select all
#! /bin/sh
### BEGIN INIT INFO
# Provides: sabnzbd, episode butler
# Short-Description: start/stop sabnzbd and episode butler web interface
### END INIT INFO
USER="username"
HOME="/home/username"
SAB_IP="192.168.1.2:8081"
SAB_USER="login"
SAB_PASS="password"
SAB_APIKEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
BUTLER_IP="192.168.1.2:8082"
BUTLER_USER="login"
BUTLER_PASS="password"
case "$1" in
start)
echo "Starting SABnzbd."
/usr/bin/sudo -u $USER -H /usr/share/SABnzbd/SABnzbd.py -d -f $HOME/.sabnzbd/sabnzbd.ini
sleep 2
echo "Starting Episode Butler."
/usr/bin/sudo -u $USER -H $HOME/.episodebutler/./episodebutler &
;;
stop)
echo "Shutting down SABnzbd."
/usr/bin/wget -q --delete-after "http://$SAB_IP/sabnzbd/api?mode=shutdown&ma_username=$SAB_USER&ma_password=$SAB_PASS&apikey=$SAB_APIKEY"
echo "Shutting down Episode Butler."
/usr/bin/wget -q --delete-after --post-data=username=$BUTLER_USER\&password=$BUTLER_PASS "http://$BUTLER_IP/quit"
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0
tret