Can't get autostart in debian 11 to work

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
NotANoobLol
Newbie
Newbie
Posts: 13
Joined: September 12th, 2017, 7:09 pm

Can't get autostart in debian 11 to work

Post by NotANoobLol »

Hey everyone,

i already tried a few things. I just want to confirm beforehand that the debian user exists (only user) and that the permissions are set.
I'm on Debian 11, headless.

I tried it with a service:

Code: Select all

$ cat /etc/systemd/system/sabnzbdplus.service.BAK
#/usr/lib/systemd/system/sabnzbdplus.service
[Unit]
Description=Sabnzbd
Wants=network-online.target
After=network-online.target

[Service]
User=debian
Group=debian
#ExecStart=sabnzbdplus --config-file /home/debian/.sabnzbd/sabnzbd.ini --logging 1 --daemon
#ExecStart=/usr/bin/sabnzbdplus --daemon
#ExecStart=/usr/bin/python3 /usr/bin/sabnzbdplus --config-file /home/debian/.sabnzbd/sabnzbd.ini --logging 1 --daemon
ExecStart=/usr/bin/python3 /usr/bin/sabnzbdplus --config-file /home/debian/.sabnzbd/sabnzbd.ini --logging 1 --daemon
Type=forking

Restart=on-failure

[Install]
WantedBy=multi-user.target
I tried it with a Cronjob in the debian crontable:

Code: Select all

@reboot /usr/bin/python3 /usr/bin/sabnzbdplus --config-file /home/debian/.sabnzbd/sabnzbd.ini --logging 1 --daemon
That also doesnt work

How do I get sabnzbd to autostart in debian?
The init.d config still needs me to start it by hand and the "enable" keyword doesn't work. Only start or stop.
User avatar
jcfp
Release Testers
Release Testers
Posts: 989
Joined: February 7th, 2008, 12:45 pm

Re: Can't get autostart in debian 11 to work

Post by jcfp »

The package ships an init.d, which will also work with systemd's compatibility mode as long as you do not add a native systemd service with the same name. That init.d script is enabled by default, but will only actually start the application after you edit /etc/default/sabnzbdplus to set the user, and afterwards tell systemd to reload the service files from disk (sudo systemctl daemon-reload).

If you insist on adding a systemd service, I suggest starting with the example at https://github.com/sabnzbd/sabnzbd/blob ... 40.service and replacing the "/opt/sabnzbd/SABnzbd.py" part in ExecStart with "/usr/bin/sabnzbdplus".
NotANoobLol
Newbie
Newbie
Posts: 13
Joined: September 12th, 2017, 7:09 pm

Re: Can't get autostart in debian 11 to work

Post by NotANoobLol »

jcfp wrote: June 23rd, 2023, 1:38 am The package ships an init.d, which will also work with systemd's compatibility mode as long as you do not add a native systemd service with the same name. That init.d script is enabled by default, but will only actually start the application after you edit /etc/default/sabnzbdplus to set the user, and afterwards tell systemd to reload the service files from disk (sudo systemctl daemon-reload).

If you insist on adding a systemd service, I suggest starting with the example at https://github.com/sabnzbd/sabnzbd/blob ... 40.service and replacing the "/opt/sabnzbd/SABnzbd.py" part in ExecStart with "/usr/bin/sabnzbdplus".
Okay so I removed my systemd entity via the rm command now. I purged sabnzbd after backing up my sabnzbd.ini. I then did a

Code: Select all

sudo systemctl daemon-reload
and reinstalled sabnzbd from the debian packages.

I configured the default:

Code: Select all

$ cat /etc/default/sabnzbdplus
# This file is sourced by /etc/init.d/sabnzbdplus
#
# When SABnzbd+ is started using the init script, the
# --daemon option is always used, and the program is
# started under the account of $USER, as set below.
#
# Each setting is marked either "required" or "optional";
# leaving any required setting unconfigured will cause
# the service to not start.

# [required] user or uid of account to run the program as:
USER=debian

# [optional] full path to the configuration file of your choice;
#            otherwise, the default location (in $USER's home
#            directory) is used:
CONFIG=/home/debian/.sabnzbd/sabnzbd.ini

# [optional] hostname/ip and port number to listen on:
HOST=debianserver
PORT=8080

# [optional] extra command line options, if any:
EXTRAOPTS=
I executed

Code: Select all

sudo systemctl daemon-reload
again and went on with

Code: Select all

$ sudo service sabnzbdplus start
The status tells me that the default isn't enabled

Code: Select all

$ sudo service sabnzbdplus status
● sabnzbdplus.service - LSB: SABnzbd+ binary newsgrabber
     Loaded: loaded (/etc/init.d/sabnzbdplus; generated)
     Active: active (exited) since Fri 2023-06-23 14:57:40 CEST; 9min ago
       Docs: man:systemd-sysv-generator(8)
      Tasks: 0 (limit: 9407)
     Memory: 0B
        CPU: 0
     CGroup: /system.slice/sabnzbdplus.service

Jun 23 14:57:40 debianserver systemd[1]: Starting LSB: SABnzbd+ binary newsgrabber...
Jun 23 14:57:40 debianserver sabnzbdplus[1725]: SABnzbd+ binary newsgrabber: service not enabled, edit /etc/default/sabnzbdplus.
Jun 23 14:57:40 debianserver systemd[1]: Started LSB: SABnzbd+ binary newsgrabber.
But enabeling doesnt work:

Code: Select all

$ sudo service sabnzbdplus enable
Usage: /etc/init.d/sabnzbdplus {start|stop|restart|force-reload|status}
Do you see my mistake? I genuenly don't
User avatar
jcfp
Release Testers
Release Testers
Posts: 989
Joined: February 7th, 2008, 12:45 pm

Re: Can't get autostart in debian 11 to work

Post by jcfp »

Do you see my mistake? I genuenly don't
Not yet ;)

What result do you get for this command:

Code: Select all

/bin/sh -c 'unset USER && . /etc/default/sabnzbdplus && [ -z "${USER%:*}" ] && echo "not enabled (USER=$USER)" || echo "enabled (USER=$USER)"'
NotANoobLol
Newbie
Newbie
Posts: 13
Joined: September 12th, 2017, 7:09 pm

Re: Can't get autostart in debian 11 to work

Post by NotANoobLol »

jcfp wrote: June 23rd, 2023, 3:26 pmWhat result do you get for this command:

Code: Select all

/bin/sh -c 'unset USER && . /etc/default/sabnzbdplus && [ -z "${USER%:*}" ] && echo "not enabled (USER=$USER)" || echo "enabled (USER=$USER)"'

Code: Select all

$ /bin/sh -c 'unset USER && . /etc/default/sabnzbdplus && [ -z "${USER%:*}" ] && echo "not enabled (USER=$USER)" || echo "enabled (USER=$USER)"'

enabled (USER=debian)
And for a good measure:

Code: Select all

$ whoami
debian
User avatar
jcfp
Release Testers
Release Testers
Posts: 989
Joined: February 7th, 2008, 12:45 pm

Re: Can't get autostart in debian 11 to work

Post by jcfp »

So it's all setup correctly, and the exact same check the init.d script does also passes. Maybe systemd is using a cached version of the default file, in spite of the daemon-reload? Does the issue persist after a reboot?
NotANoobLol
Newbie
Newbie
Posts: 13
Joined: September 12th, 2017, 7:09 pm

Re: Can't get autostart in debian 11 to work

Post by NotANoobLol »

jcfp wrote: June 24th, 2023, 1:34 am So it's all setup correctly, and the exact same check the init.d script does also passes. Maybe systemd is using a cached version of the default file, in spite of the daemon-reload? Does the issue persist after a reboot?
Yes I rebooted a bunch of times at this point.

Was there maybe something wrong with how I removed the systemd entity?

I basically just removed it from /etc/systemd/system via

Code: Select all

sudo rm

Edit: I figured it out, that was indeed my issue.

I did this and everything is running now:

Code: Select all

sudo systemctl disable sabnzbdplus
sabnzbdplus.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable sabnzbdplus
there was still something in the /lib/systemd folder.

Thank you so much for your help! We Finally got there :D
NotANoobLol
Newbie
Newbie
Posts: 13
Joined: September 12th, 2017, 7:09 pm

Re: Can't get autostart in debian 11 to work

Post by NotANoobLol »

jcfp wrote: June 24th, 2023, 1:34 am So it's all setup correctly, and the exact same check the init.d script does also passes. Maybe systemd is using a cached version of the default file, in spite of the daemon-reload? Does the issue persist after a reboot?
Hey, sorry to grab this thread out. I was afk for a few weeks.

So after we fixed the weird systemd issue I am now indeed using the init.d file.

However I can't connect via browser but everything is (apperantly) running and set up correctly.

Code: Select all

$ sudo service sabnzbdplus status
● sabnzbdplus.service - LSB: SABnzbd+ binary newsgrabber
     Loaded: loaded (/etc/init.d/sabnzbdplus; generated)
     Active: active (running) since Mon 2023-07-31 13:53:18 CEST; 2min 5s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 840 ExecStart=/etc/init.d/sabnzbdplus start (code=exited, status=0/SUCCESS)
      Tasks: 23 (limit: 9407)
     Memory: 70.4M
        CPU: 3.503s
     CGroup: /system.slice/sabnzbdplus.service
             └─987 /usr/bin/python3 -OO /usr/bin/sabnzbdplus --daemon --pidfile /var/run/sabnzbdplus/pid --config-file /home/debian/.sabnzbd/sabnzbd.ini

Jul 31 13:53:15 debianserver systemd[1]: Starting LSB: SABnzbd+ binary newsgrabber...
Jul 31 13:53:18 debianserver sabnzbdplus[840]: Starting SABnzbd+ binary newsgrabber:.
Jul 31 13:53:18 debianserver systemd[1]: Started LSB: SABnzbd+ binary newsgrabber.
Configs:

Code: Select all

$ cat /etc/default/sabnzbdplus
# This file is sourced by /etc/init.d/sabnzbdplus
#
# When SABnzbd+ is started using the init script, the
# --daemon option is always used, and the program is
# started under the account of $USER, as set below.
#
# Each setting is marked either "required" or "optional";
# leaving any required setting unconfigured will cause
# the service to not start.

# [required] user or uid of account to run the program as:
USER=debian

# [optional] full path to the configuration file of your choice;
#            otherwise, the default location (in $USER's home
#            directory) is used:
CONFIG=/home/debian/.sabnzbd/sabnzbd.ini

# [optional] hostname/ip and port number to listen on:
HOST=debianserver
PORT=8080

# [optional] extra command line options, if any:
EXTRAOPTS=

Code: Select all

$ cat /home/debian/.sabnzbd/sabnzbd.ini
__version__ = 19
__encoding__ = utf-8
[misc]
pre_script = None
REST IS REDACTED BUT CONTENTS INCLUDE USERNAME/PW AND SO ON
So everything is apperantly up, running and correctly configured. But when I want to connect via the browser I just get the standard message of the browser when it can't connect to a website/service.

However as soon as I do this

Code: Select all

$ sudo service sabnzbdplus restart
It runs normally and I can connect to it via the browser??
Post Reply