Ubuntu systemd script for PPA

Support for the Debian/Ubuntu package, created by JCFP.
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
mason
Newbie
Newbie
Posts: 6
Joined: April 28th, 2008, 5:56 am

Ubuntu systemd script for PPA

Post by mason »

Hey there,

since I'm in the process of swapping my old 12.04 server to new hardware and 16.10 I stumbled over a missing systemd script for sabnzbd. So after some digging, here are my findings to share. Maybe it's helping someone.

Create a new systemd script with

Code: Select all

sudo nano /etc/systemd/system/sabnzbd.service
Add the following:

Code: Select all

[Unit]
Description=Sabnzbd
Wants=network-online.target
After=network-online.target

[Service]
User=sabuser
Group=sabuser
RuntimeDirectory=sabnzbdplus
RuntimeDirectoryMode=0750
ExecStart=/usr/bin/python2.7 /usr/bin/sabnzbdplus --config-file /home/sabuser/.sabnzbd/sabnzbd.ini --logging 1 --daemon
Type=forking

Restart=on-failure

[Install]
WantedBy=multi-user.target
Some things I fell over. We need to create the sabnzbd pid dir in /var/run due to the fact that we running under a different user which has no permissions there. So that's what's the RuntimeDirectory directive is for.
Make sure you edit the user, location of the ini file and port to match your configuration. Type is forking since sabnzbd spawns other threads.

Enable the systemd with:

Code: Select all

sudo systemctl enable sabnzbd.service 
Then just start with

Code: Select all

sudo service sabnzbd start
and you should be good. Hope this might help somebody... finally could give something back. :)

Cheers
Last edited by mason on January 27th, 2017, 6:42 am, edited 2 times in total.
User avatar
jcfp
Release Testers
Release Testers
Posts: 1004
Joined: February 7th, 2008, 12:45 pm

Re: Ubuntu systemd script for PPA

Post by jcfp »

Have been thinking about adding a systemd service for a while, but haven't so far as I'm still looking for the best way to handle existing users during upgrade, initial service configuration, and related systemd "features".

And just for the record: without a native service, systemd will simply use the good old init.d script.
mason
Newbie
Newbie
Posts: 6
Joined: April 28th, 2008, 5:56 am

Re: Ubuntu systemd script for PPA

Post by mason »

Also looks like it having a flaw, if your restart in the browser, it won't come back.... need to have another look.

Now it's working as it should, and proper restarting from the GUI.
Post Reply