Manage SABnzbdplus through terminal & Scripting help

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
josiahrulez
Newbie
Newbie
Posts: 6
Joined: March 8th, 2012, 1:01 pm

Manage SABnzbdplus through terminal & Scripting help

Post by josiahrulez »

Hey all, so my download box has need reformatting twice in the last few months. Ubuntu broke it self in a distro upgrade, and the OS HDD died last week. And it was a bitch to reformat, install and configure everything again.

So what i want to do, is write a script to automatically install and configure SABnzbdplus and get its API key and give it to Sick-Beard and CouchPotato
-Set it to use english
-Put in my news hoster details
-and select a folder to watch for nzbs
-print API key so i can give it to Sick-Beard and CouchPotato
How would i do this via terminal?

So far I've got it to install the applications and start msot of the applications automatically at startup, i just need help with the bit above. And i want to try backup my SABnzbdplus folder daily, will i have any issues? (If i try backup while SABnzbdplus is accessing/writing to files?)

My script so far.

Code: Select all

#!/bin/bash
# I need to finish off headphones, transmission and add the rules to the firewall

intro()
{	clear
	echo -e "\e[1;32m __________________________________________________________________"
	echo "|                                                                  |"
	echo "| Hey all,                                                         |"
	echo "|                                                                  |" 
	echo "|                                                                  |" 
	echo "| -This will install the following applications                    |"
 	echo "|   *SABnzbd+      (Download Manager, NZB News Reader)             |"
	echo "|   *SickBeard     (Automatic TV Downloading, NZB & Torrents)      |"
	echo "|   *CouchPotato   (Automatic Movie Downloading, NZB & Torrents)   |"
	echo "|   *HeadPhones    (Automatic Music Downloading, NZB)              |"
	echo "|   *Jdownloader   (Download Manager, Direct Downloads)            |"  
	echo "|   *Transmission  (Download Manager, Torrents)                    |" 	
	echo "|   *Git-Core                                                      |" 
	echo "|   & All dependencies                                             |"
	echo "|                                                                  |" 
	echo "| -Set them to start automatically when the system starts          |"
	echo "|__________________________________________________________________|"
	echo -e "\e[0m"
}

credits()
{	clear
	echo -e "\e[1;32m ______________________________________________________"
	echo "|                                                      |"
	echo "|                                                      |"
	echo "|  Hopefully everything installed ok                   |"
	echo "|                                                      |"
	echo "|                                                      |"
	echo "|______________________________________________________|"
	echo -e "\e[0m"
}


git-core()
{
# Installs Git-core, the Github clone installer thing for linux
apt-get install -y git-core
sleep 2
}

sabnzbd()
{
apt-get install -y sabnzbdplus
# Installs SABnzbd+
sleep 2
# Launches sabnzbdplus
sabnzbdplus
sleep 2
sed -i "s/USER=/&$username/" /etc/default/sabnzbdplus
}

couchpotato()
{
cd /home/$username/
# Clones the Git Hub source code for Couchpotato
git clone https://github.com/RuudBurger/CouchPotatoServer.git
sleep 2
# Launches the CouchPotato python script 
python /home/$username/CouchPotatoServer/CouchPotato.py
sleep 5
# Moves the init script to /etc/init.d/couchpotato
cp /home/$username/CouchPotatoServer/init/ubuntu /etc/init.d/couchpotato
sleep 2
# Adds $USER after RUN_AS=
sed -i "s/RUN_AS=/&$username # /" /etc/init.d/couchpotato
# Adds /home/$USER/CouchPotatoServer after APP_PATH=
sed -i "s,APP_PATH=,&/home/$username/CouchPotatoServer # ," /etc/init.d/couchpotato
sleep 2
# Makes /etc/init.d/couchpotato executable 
chmod +x /etc/init.d/couchpotato
sleep 2
# Adds it to the defaults
update-rc.d couchpotato defaults
sleep 2
# Gives Read/Write permissions to all users
chmod -R 777 /home/$username/CouchPotatoServer
}

sickbeard()
{
cd /home/$username/
# Clones the Git Hub source code for Sick-Beard
git clone https://github.com/midgetspy/Sick-Beard.git
sleep 2
# Launches the Sick-Beard python script
python /home/$username/Sick-Beard/SickBeard.py
sleep 5
# Moves the init script to /etc/init.d/Sick-Beard
cp /home/$username/Sick-Beard/init.ubuntu /etc/init.d/Sick-Beard
sleep 2
# Adds $USER after RUN_AS=
sed -i "s/RUN_AS=/&$username # /" /etc/init.d/Sick-Beard
sleep 2
# Adds /home/$USER/Sick-Beard after APP_PATH=
sed -i "s,APP_PATH=,&/home/$username/Sick-Beard # ," /etc/init.d/Sick-Beard
sleep 2
# Adds /home/$USER/Sick-Beard after DATA_DIR=
sed -i "s,DATA_DIR=,&/home/$username/Sick-Beard # ," /etc/init.d/Sick-Beard
sleep 2
# Makes /etc/init.d/Sick-Beard executable 
chmod +x /etc/init.d/Sick-Beard
sleep 2
# Adds it to the defaults
update-rc.d Sick-Beard defaults
sleep 2
# Gives Read/Write permissions to all users
chmod -R 777 /home/$username/Sick-Beard
}

headphones()
{
cd /home/$username/
# Clones the Git Hub source code for HeadPhones
git clone https://github.com/rembo10/headphones.git
sleep 2 
# Launches the HeadPhones python script
python /home/$username/headphones/Headphones.py
sleep 5
# Moves the init script to /etc/init.d/init.ubuntu
cp /home/$username/headphones/init.ubuntu /etc/init.d/headphones
# Adds $USER after RUN_AS=
sed -i "s/RUN_AS=/&$username # /" /etc/init.d/headphones
# Adds /home/$USER/headphones after DATA_DIR=
sed -i "s,APP_PATH=,&/home/$username/Sick-Beard # ," /etc/init.d/headphones
sleep 2
# Makes /etc/init.d/headphones executable 
chmod +x /etc/init.d/headphones
sleep 2
# Adds it to the defaults
update-rc.d headphones defaults
sleep 2
# Gives Read/Write permissions to all users
chmod -R 777 /home/$username/headphones
}

jdownloader()
{
# Adds the JDownloader repository
add-apt-repository -y ppa:jd-team/jdownloader
sleep 2
apt-get update
# Updates the repositories
sleep 2
# Installs Jdownloader
apt-get install -y jdownloader
sleep 2
}

transmission()
{
# Moves the Transmission shortcut to the autostart folder
# cat << EOF >> ~/.config/autostart/name.desktop # Doesn't work, need new method
# [Desktop Entry]
# Type=Application
# Exec=transmission-gtk -m
# Name=Transmission
# Comment=whatever 
# EOF
echo lol skip this bit, its broken
}

firewall()
{
# Allows SABnzbd+ through the firewall, so it can be remotely managed by its webGUI
ufw allow 8080
sleep 1
# Allows CouchPotato through the firewall, so it can be remotely managed by its webGUI
ufw allow 5050
sleep 1
# Allows Sick-Beard through the firewall, so it can be remotely managed by its webGUI
ufw allow 8081
sleep 1
# Allows HeadPhones through the firewall, so it can be remotely managed by its webGUI
# ufw allow - Check which port headphones uses for its remote management
sleep 1
# Allows Jdownloader through the firewall, so it can be remotely managed by its webGUI
ufw allow 10025
sleep 1
# Allows Transmission through the firewall, so it can be remotely managed by its webGUI
ufw allow 9091
sleep 1
}

{
# Runs the intro section
intro
	echo -e "\e[1;32m" "What is your username?" "\e[0m" & read -p "  : " username
	echo ""

	
# Information
echo -e "\e[1;32m" "Installing Git-Core..." "\e[0m"	
	# Starts the git-core section
	git-core
	
# Information
echo -e "\e[1;32m" "Installing SABnzbd+..." "\e[0m"
	# Starts the sabnzbd section
	sabnzbd
	
# Information
echo -e "\e[1;32m" "Installing CouchPotato..." "\e[0m"
	# Starts the couchpotato section
	couchpotato

# Information
echo -e "\e[1;32m" "Installing Sick-Beard..." "\e[0m"
	# Starts the sickbeard section
	sickbeard
	
# Information
echo -e "\e[1;32m" "Installing HeadPhones..." "\e[0m"
	# Starts the headphones section
	headphones

# Information
echo -e "\e[1;32m" "Installing JDownloader..." "\e[0m"
	# Starts the jdownloader section
	jdownloader
	
# Information
echo -e "\e[1;32m" "Configuring Transmission..." "\e[0m"
	# Starts the transmission section
	transmission	
	
# Information
echo -e "\e[1;32m" "Updating Firewall Rules..." "\e[0m"
	# Starts the firewall section
	firewall
	
# Runs the credits section
credits
	# Displays a prompt for the user, he needs to press a key to continue
	echo -e "\e[1;32m"
	echo " "
	read -n1 -r -p "               Press Any Key To Continue..." key
	echo -e "\e[0m"
}



User avatar
sander
Release Testers
Release Testers
Posts: 9264
Joined: January 22nd, 2008, 2:22 pm

Re: Manage SABnzbdplus through terminal & Scripting help

Post by sander »

Interesting. How do you avoid that the SABnzbd wizard starts? Or is the wizard OK for you?
josiahrulez
Newbie
Newbie
Posts: 6
Joined: March 8th, 2012, 1:01 pm

Re: Manage SABnzbdplus through terminal & Scripting help

Post by josiahrulez »

sander wrote:Interesting. How do you avoid that the SABnzbd wizard starts? Or is the wizard OK for you?
Well I'd like it to silent install everything and configure most of it for me, thats why i need help

How can i fill in the start wizard via command prompt and then generate and print out an API key (Without using a web browser?)
User avatar
sander
Release Testers
Release Testers
Posts: 9264
Joined: January 22nd, 2008, 2:22 pm

Re: Manage SABnzbdplus through terminal & Scripting help

Post by sander »

Depends on what you want. Some ideas:

- follow the wizard, and then keep a backup of sabnzbd.ini
or
- take an existing sabnzbd.ini, and replace a few relevant items (newsserver setting, ...) by a parameter, and use that as a templte. Then use sed to replace those parameters by the real value to create an real instance of sabnzbd.ini
or
- (experiment) create a zero-size sabnzbd.ini ('touch sabnzbd.ini'), start SABnbzd and see what happens ... maybe SABnzbd fills out all missing parameters with a default value?
Post Reply