Difference between revisions of "SABnzbd"

From ArchWiki
Jump to: navigation, search
(Added: "SABnzbd redirects to localhost on remonte access when only https is enabled" + fix)
m (a few style improvements)
 
(35 intermediate revisions by 14 users not shown)
Line 1: Line 1:
[[Category:Internet Applications]]
+
[[Category:Internet applications]]
SABnzbd is an Open Source Binary Newsreader written in Python.
+
SABnzbd is an open-source binary newsreader written in Python.
  
''It's totally free, incredibly easy to use, and works practically everywhere. SABnzbd makes Usenet as simple and streamlined as possible by automating everything we can. All you have to do is add an .nzb. SABnzbd takes over from there, where it will be automatically downloaded, verified, repaired, extracted and filed away with zero human interaction.''
+
From [http://sabnzbd.org/ sabnzbd.org]:
 +
:It's totally free, incredibly easy to use, and works practically everywhere. SABnzbd makes Usenet as simple and streamlined as possible by automating everything we can. All you have to do is add an .nzb. SABnzbd takes over from there, where it will be automatically downloaded, verified, repaired, extracted and filed away with zero human interaction.
  
 
== Installation ==
 
== Installation ==
Install {{AUR|sabnzbd}} from the [[Arch User Repository]].
 
  
== Configuration ==
+
Install the {{AUR|sabnzbd}} or {{AUR|sabnzbd-git}} package.
=== systemd ===
+
SABnzbd comes with a system service file, this can be used to control the daemon as follows:
+
#systemctl {start,stop,enable,disable} sabnzbd.service
+
  
{{ic|start}} and {{ic|stop}} are direct, {{ic|enable}} and {{ic|disable}} configure automatic starting of the service during boot. For more information, refer to the [[Systemd]] article.
+
== Configuration  ==
 +
SABnzbd is able to run globally (settings apply to all users) and locally (per user settings). The way of setting up SABnzbd depends on the way it is intended to be used. A local configuration may prove more useful on a desktop system when used by several people simultaneously.
  
It is recommended to run through the initial setup wizard after starting the service by going to 127.0.0.1:8080 in your favourite web-browser. This initial setup should be enough to get SABnzbd working correctly for regular users. Users wanting HTTPS access are recommended to read further on in [https://wiki.archlinux.org/index.php/SABnzbd#enabling_https enabling https].
+
=== Starting SABnzbd ===
  
=== enabling https ===
+
The {{AUR|sabnzbd}} package provides a {{ic|sabnzbd}} [[systemd]] service.
enabling https is a threefold process:
+
 
 +
It is however possible to start SABnzbd using the following command:
 +
 
 +
$ sudo -u sabnzbd -H /opt/sabnzbd/SABnzbd.py -f /opt/sabnzbd/sabnzbd.ini
 +
 
 +
=== Running as daemon ===
 +
 
 +
Append the {{ic|-d}} parameter to start SABnzbd as [[daemon]]:
 +
 
 +
$ sudo -u sabnzbd -H /opt/sabnzbd/SABnzbd.py -f /opt/sabnzbd/sabnzbd.ini -d
 +
 
 +
=== Stopping SABnzbd ===
 +
 
 +
{{Note|SABnzbd can be easily shutdown by opening the main menu from the web-interface.}}
 +
 
 +
You need to know the {{ic|host}}, {{ic|port}} and {{ic|API-key}}, which can all be found using the WebUI or by searching through {{ic|/opt/sabnzbd/sabnzbd.ini}}.
 +
 
 +
Execute the following command to shutdown SABnzbd:
 +
 
 +
$ curl "http://host:port/sabnzbd/api?mode=shutdown&apikey=API-key"
 +
 
 +
=== Accessing the web-interface ===
 +
 
 +
{{Tip|
 +
*SABnzbd can only be accessed on the running computer. Change {{ic|1=host = 127.0.0.1}} in {{ic|/opt/sabnzbd/sabnzbd.ini}} to {{ic|1=host = 0.0.0.0}} (or the host IP-address) to allow access from another computer.
 +
*SABnzbd listens on port {{ic|8080}}. Change {{ic|1=port = 8080}} in {{ic|/opt/sabnzbd/sabnzbd.ini}} to the preferred port.
 +
}}
 +
 
 +
After starting SABnzbd, access the web-interface by browsing to http://127.0.0.1:8080.
 +
 
 +
=== Local configuration ===
 +
 
 +
{{Out of date|Instructions not clear, why .xinitrc, etc.}}
 +
 
 +
SABnzbd does not need to be run globally as a daemon and can rather work per user. The usual method to configure SABnzbd globally is because the listed files and folders in the default configuration file point to directories owned by sabnzbd (the {{ic|/opt/sabnzbd}} directory).
 +
 
 +
A less used (but perhaps more sensible) method is to make SABnzbd work with files and directories owned by a normal user. Running SABnzbd as a normal user has the benefits of:
 +
 
 +
* A single directory {{ic|~/.sabnzbd.ini}} (or any other directory under {{ic|/home/username}}) that will contain all the SABnzbd configuration files.
 +
* Easier to avoid unforeseen read/write permission errors.
 +
 
 +
In this case, we will use {{ic|~/.sabnzbd.ini/sabnzbd.ini}} and not start sabnzbd.service as a daemon for the whole system and all users.
 +
We will NOT use the {{ic|/usr/lib/systemd/system/sabnzbd.service}} which is intended to start the sabnzbd.service for all users.
 +
If you already enabled it, just disable it first:
 +
{{bc| # systemctl disable sabnzbd.service}}
 +
 
 +
If you used to start SABnzbd inside your {{ic|~/.xinitrc}}, comment or delete the line
 +
{{bc|sabnzbd -d}}
 +
 
 +
Then, edit a new file /etc/systemd/user/sabnzbd.service
 +
{{hc|/etc/systemd/user/sabnzbd.service|
 +
[Unit]
 +
Description = SABnzbd binary newsreader
 +
 
 +
[Service]
 +
EnvironmentFile = /etc/conf.d/sabnzbd_systemd
 +
ExecStart = /bin/sh -c "python2 ${SABNZBD_DIR}/SABnzbd.py ${SABNZBD_ARGS} --pid /tmp"
 +
ExecStop = /usr/bin/curl -f "${SABNZBD_PROTOCOL}://${SABNZBD_USPW}${SABNZBD_IP}:${SABNZBD_PORT}/sabnzbd/api?mode=shutdown&apikey=${SABNZBD_KEY}"
 +
Type = forking
 +
PIDFile = /tmp/sabnzbd-8080.pid
 +
 
 +
[Install]
 +
WantedBy = default.target
 +
}}
 +
 
 +
Then, change this line in /etc/conf.d/sabnzbd_systemd
 +
{{hc|/etc/conf.d/sabnzbd_systemd|
 +
SABNZBD_ARGS=-f ${HOME}/.sabnzbd.ini -s ${SABNZBD_IP}:${SABNZBD_PORT} -d
 +
}}
 +
 
 +
Then, add this line if not already to [[.xinitrc]]
 +
{{hc|~/.xinitrc|
 +
#run systemd as user intsance
 +
systemd --user &
 +
}}
 +
 
 +
Now, enable and start sabnzbd.service as per user
 +
$ systemctl --user enable sabnzbd
 +
$ systemctl --user start sabnzbd
 +
 
 +
Check the SABnzbd status and see if sabnzbd.service is correctly enabled and started
 +
{{bc|$ systemctl --user status sabnzbd}}
 +
 
 +
==== Running as user without systemd user instance ====
 +
 
 +
If you dont like the local configuration option, you may run sabnzbd as a user by doing this instead:
 +
$ cp /usr/lib/systemd/system/sabnzbd.service /etc/systemd/system/sabnzbd.service
 +
 
 +
Then edit :
 +
{{hc|/etc/systemd/system/sabnzbd.service|2=
 +
[Unit]
 +
Description = SABnzbd binary newsreader
 +
 
 +
[Service]
 +
ExecStart = /bin/sh -c "python2 /opt/sabnzbd/SABnzbd.py -l0 -f /home/m/.sabnzbd/sabnzbd.ini -d --pid /tmp"
 +
Type = forking
 +
PIDFile = /tmp/sabnzbd-8080.pid
 +
User = desired_user_name
 +
Group = desired_group_name
 +
[Install]
 +
WantedBy = default.target
 +
}}
 +
 
 +
== Tips and tricks ==
 +
 
 +
=== Enabling HTTPS ===
 +
 
 +
{{Out of date|Instructions out-of-dated, no {{ic|PIDFile}}, global vs local not clear.}}
 +
Enabling https is a threefold process.
 +
 
 +
For global configuration:
  
 
* edit {{ic|/opt/sabnzbd/sabnzbd.ini}} and set '''enable_https''' to {{ic|1}}
 
* edit {{ic|/opt/sabnzbd/sabnzbd.ini}} and set '''enable_https''' to {{ic|1}}
Line 24: Line 132:
  
 
* reload systemd with {{ic|# systemctl --system daemon-reload}}
 
* reload systemd with {{ic|# systemctl --system daemon-reload}}
 +
 +
For local configuration:
 +
 +
* edit {{ic|/opt/sabnzbd/sabnzbd.ini}} and set '''enable_https''' to {{ic|1}}
 +
 +
* then edit {{ic|/etc/systemd/user/sabnzbd.service}} and set '''PIDFile''' to {{ic|/tmp/sabnzbd-9090.pid}}
 +
 +
* reload systemd with {{ic|$ systemctl --user daemon-reload}}
  
 
You should now be able to start sabnzbd with SSL support.
 
You should now be able to start sabnzbd with SSL support.
  
=== using a custom port ===
+
=== Using a custom port ===
Using a custom port is similar to using https:
+
 
 +
{{Out of date|Instructions out-of-dated, no {{ic|PIDFile}}, global vs local not clear.}}
 +
 
 +
Using a custom port is similar to using https.
 +
 
 +
For global configuration:
  
 
* edit {{ic|/opt/sabnzbd/sabnzbd.ini}} and set '''port''' in '''[misc]''' section to the port you wish to use.
 
* edit {{ic|/opt/sabnzbd/sabnzbd.ini}} and set '''port''' in '''[misc]''' section to the port you wish to use.
Line 38: Line 159:
 
* reload systemd with {{ic|# systemctl --system daemon-reload}}
 
* reload systemd with {{ic|# systemctl --system daemon-reload}}
  
You should now be able to start sabnzbd with a custom port.
+
For local configuration:
  
== Troubleshooting ==
+
* edit {{ic|/opt/sabnzbd/sabnzbd.ini}} and set '''port''' in '''[misc]''' section to the port you wish to use.
=== systemd times out when starting SABnzbd with https enabled ===
+
When faced with the following:
+
[user@host ~]$ sudo systemctl start sabnzbd.service
+
Job failed. See system journal and 'systemctl status' for details.
+
+
[user@host ~]$ sudo systemctl status sabnzbd.service
+
sabnzbd.service - SABnzbd binary newsreader
+
  Loaded: loaded (/usr/lib/systemd/system/sabnzbd.service; disabled)
+
  Active: failed (Result: timeout) since Tue, 25 Sep 2012 20:10:47 +0200; 9s ago
+
  CGroup: name=systemd:/system/sabnzbd.service
+
  
It's likely that you've forgotten to edit {{ic|sabnzbd.service}} to reflect the proper PID file as mentioned in [https://wiki.archlinux.org/index.php/SABnzbd#enabling_https enabling https].
+
* then edit {{ic|/etc/systemd/user/sabnzbd.service}} and set '''PIDFile''' to {{ic|/tmp/sabnzbd-''yourport''.pid}} where ''yourport'' is the same as set in the first step.
  
=== SABnzbd redirects to localhost on remonte access when only https is enabled ===
+
* edit {{ic|/etc/conf.d/sabnzbd_systemd}} and set '''SABNZBD_PORT''' to the port set in the first step.
This strange issue seems to appear, when you have no https port configured (so it will use the configured http port for http) and your {{ic|/etc/conf.d/sabnzbd[_systemd]}} says
+
 
SABNZBD_PROTOCOL=https
+
* reload systemd with {{ic|$ systemctl --user daemon-reload}}
instead of:
+
 
SABNZBD_PROTOCOL=http
+
You should now be able to start sabnzbd with a custom port.
  
You might need to restart your clientside browser.
+
== See also ==
  
== External Links ==
 
 
* [http://sabnzbd.org/ SABnzbd homepage]
 
* [http://sabnzbd.org/ SABnzbd homepage]
 
* [http://wiki.sabnzbd.org/ SABnzbd wiki]
 
* [http://wiki.sabnzbd.org/ SABnzbd wiki]

Latest revision as of 07:08, 22 March 2016

SABnzbd is an open-source binary newsreader written in Python.

From sabnzbd.org:

It's totally free, incredibly easy to use, and works practically everywhere. SABnzbd makes Usenet as simple and streamlined as possible by automating everything we can. All you have to do is add an .nzb. SABnzbd takes over from there, where it will be automatically downloaded, verified, repaired, extracted and filed away with zero human interaction.

Installation

Install the sabnzbdAUR or sabnzbd-gitAUR package.

Configuration

SABnzbd is able to run globally (settings apply to all users) and locally (per user settings). The way of setting up SABnzbd depends on the way it is intended to be used. A local configuration may prove more useful on a desktop system when used by several people simultaneously.

Starting SABnzbd

The sabnzbdAUR package provides a sabnzbd systemd service.

It is however possible to start SABnzbd using the following command:

$ sudo -u sabnzbd -H /opt/sabnzbd/SABnzbd.py -f /opt/sabnzbd/sabnzbd.ini

Running as daemon

Append the -d parameter to start SABnzbd as daemon:

$ sudo -u sabnzbd -H /opt/sabnzbd/SABnzbd.py -f /opt/sabnzbd/sabnzbd.ini -d

Stopping SABnzbd

Note: SABnzbd can be easily shutdown by opening the main menu from the web-interface.

You need to know the host, port and API-key, which can all be found using the WebUI or by searching through /opt/sabnzbd/sabnzbd.ini.

Execute the following command to shutdown SABnzbd:

$ curl "http://host:port/sabnzbd/api?mode=shutdown&apikey=API-key"

Accessing the web-interface

Tip:
  • SABnzbd can only be accessed on the running computer. Change host = 127.0.0.1 in /opt/sabnzbd/sabnzbd.ini to host = 0.0.0.0 (or the host IP-address) to allow access from another computer.
  • SABnzbd listens on port 8080. Change port = 8080 in /opt/sabnzbd/sabnzbd.ini to the preferred port.

After starting SABnzbd, access the web-interface by browsing to http://127.0.0.1:8080.

Local configuration

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: Instructions not clear, why .xinitrc, etc. (Discuss in Talk:SABnzbd#)

SABnzbd does not need to be run globally as a daemon and can rather work per user. The usual method to configure SABnzbd globally is because the listed files and folders in the default configuration file point to directories owned by sabnzbd (the /opt/sabnzbd directory).

A less used (but perhaps more sensible) method is to make SABnzbd work with files and directories owned by a normal user. Running SABnzbd as a normal user has the benefits of:

  • A single directory ~/.sabnzbd.ini (or any other directory under /home/username) that will contain all the SABnzbd configuration files.
  • Easier to avoid unforeseen read/write permission errors.

In this case, we will use ~/.sabnzbd.ini/sabnzbd.ini and not start sabnzbd.service as a daemon for the whole system and all users. We will NOT use the /usr/lib/systemd/system/sabnzbd.service which is intended to start the sabnzbd.service for all users. If you already enabled it, just disable it first:

 # systemctl disable sabnzbd.service

If you used to start SABnzbd inside your ~/.xinitrc, comment or delete the line

sabnzbd -d

Then, edit a new file /etc/systemd/user/sabnzbd.service

/etc/systemd/user/sabnzbd.service
[Unit]
Description = SABnzbd binary newsreader

[Service]
EnvironmentFile = /etc/conf.d/sabnzbd_systemd
ExecStart = /bin/sh -c "python2 ${SABNZBD_DIR}/SABnzbd.py ${SABNZBD_ARGS} --pid /tmp"
ExecStop = /usr/bin/curl -f "${SABNZBD_PROTOCOL}://${SABNZBD_USPW}${SABNZBD_IP}:${SABNZBD_PORT}/sabnzbd/api?mode=shutdown&apikey=${SABNZBD_KEY}"
Type = forking
PIDFile = /tmp/sabnzbd-8080.pid

[Install]
WantedBy = default.target

Then, change this line in /etc/conf.d/sabnzbd_systemd

/etc/conf.d/sabnzbd_systemd
SABNZBD_ARGS=-f ${HOME}/.sabnzbd.ini -s ${SABNZBD_IP}:${SABNZBD_PORT} -d

Then, add this line if not already to .xinitrc

~/.xinitrc
#run systemd as user intsance
systemd --user &

Now, enable and start sabnzbd.service as per user

$ systemctl --user enable sabnzbd
$ systemctl --user start sabnzbd

Check the SABnzbd status and see if sabnzbd.service is correctly enabled and started

$ systemctl --user status sabnzbd

Running as user without systemd user instance

If you dont like the local configuration option, you may run sabnzbd as a user by doing this instead:

$ cp /usr/lib/systemd/system/sabnzbd.service /etc/systemd/system/sabnzbd.service

Then edit :

/etc/systemd/system/sabnzbd.service
[Unit]
Description = SABnzbd binary newsreader

[Service]
ExecStart = /bin/sh -c "python2 /opt/sabnzbd/SABnzbd.py -l0 -f /home/m/.sabnzbd/sabnzbd.ini -d --pid /tmp"
Type = forking
PIDFile = /tmp/sabnzbd-8080.pid
User = desired_user_name
Group = desired_group_name
[Install]
WantedBy = default.target

Tips and tricks

Enabling HTTPS

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: Instructions out-of-dated, no PIDFile, global vs local not clear. (Discuss in Talk:SABnzbd#)

Enabling https is a threefold process.

For global configuration:

  • edit /opt/sabnzbd/sabnzbd.ini and set enable_https to 1
  • copy /usr/lib/systemd/system/sabnzbd.service to /etc/systemd/system/ then edit it and set PIDFile to /run/sabnzbd/sabnzbd-9090.pid
  • reload systemd with # systemctl --system daemon-reload

For local configuration:

  • edit /opt/sabnzbd/sabnzbd.ini and set enable_https to 1
  • then edit /etc/systemd/user/sabnzbd.service and set PIDFile to /tmp/sabnzbd-9090.pid
  • reload systemd with $ systemctl --user daemon-reload

You should now be able to start sabnzbd with SSL support.

Using a custom port

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: Instructions out-of-dated, no PIDFile, global vs local not clear. (Discuss in Talk:SABnzbd#)

Using a custom port is similar to using https.

For global configuration:

  • edit /opt/sabnzbd/sabnzbd.ini and set port in [misc] section to the port you wish to use.
  • copy /usr/lib/systemd/system/sabnzbd.service to /etc/systemd/system/ then edit it and set PIDFile to /run/sabnzbd/sabnzbd-yourport.pid where yourport is the same as set in the first step.
  • edit /etc/conf.d/sabnzbd_systemd and set SABNZBD_PORT to the port set in the first step.
  • reload systemd with # systemctl --system daemon-reload

For local configuration:

  • edit /opt/sabnzbd/sabnzbd.ini and set port in [misc] section to the port you wish to use.
  • then edit /etc/systemd/user/sabnzbd.service and set PIDFile to /tmp/sabnzbd-yourport.pid where yourport is the same as set in the first step.
  • edit /etc/conf.d/sabnzbd_systemd and set SABNZBD_PORT to the port set in the first step.
  • reload systemd with $ systemctl --user daemon-reload

You should now be able to start sabnzbd with a custom port.

See also