Page 1 of 1

Sabnzbd won't start as a service on Ubuntu 11.04

Posted: August 3rd, 2011, 3:50 pm
by oxseyn
My server is Ubuntu 11.04 x64 Server Edition. I installed Sabnzbd+ using the ppa per the instructions.
I can run it using my account, but not as a service.

Here's the installation steps I used:

Created the media group & sabnzbdplus service account:
sudo groupadd media
sudo useradd -r sabnzbdplus -G media

(My user account & the sickbeard service account are also in the media group)

I then created my sabnzbdplus directory structure:

sudo mkdir /mnt/nas/sabnzbdplus
sudo mkdir /mnt/nas/sabnzbdplus/admin
sudo mkdir /mnt/nas/sabnzbdplus/backup
sudo mkdir /mnt/nas/sabnzbdplus/downloads
sudo mkdir /mnt/nas/sabnzbdplus/downloads/complete
sudo mkdir /mnt/nas/sabnzbdplus/downloads/temporary
sudo mkdir /mnt/nas/sabnzbdplus/logs
sudo mkdir /mnt/nas/sabnzbdplus/nzb-backup
sudo mkdir /mnt/nas/sabnzbdplus/watch
sudo cp ~/.sabnzbd/sabnzbd.ini /mnt/nas/sabnzbdplus/config.ini

Fixed the permissions on the directory:

sudo chown root:media -R /mnt/nas/sabnzbdplus
sudo chmod 775 -R /mnt/nas/sabnzbdplus

And then modified the /etc/default/sabnzbdplus config with the follow entries:
USER=sabnzbdplus
CONFIG=/mnt/nas/sabnzbdplus/config.ini

And then I attempted to start the service ...
sudo /etc/init.d/sabnzbdplus start

And the service fails to start - it just says starting daemon and [Fail].

However, if I run it from my own account, it starts and runs just fine. When I browse to the website, I see it's using the configuration file from my directory, not the one specified in the /etc/default/sabnzbdplus file.

Any ideas what I've mucked up?

Re: Sabnzbd won't start as a service on Ubuntu 11.04

Posted: August 4th, 2011, 1:44 am
by sander
First things first:

Make sure there is no SABnzbd running, otherwise the port is already in use.
Then - as a test - replace USER and CONFIG in /etc/default/sabnzbdplus with your own account and your own config (probably in ~/.sabnzbd/sabnzbd.ini).
Then start to start the daemon again. That works for me:

Code: Select all

ubuntu@ubuntu:~$ sudo service sabnzbdplus start
 * Starting SABnzbd+ binary newsgrabber                                  [ OK ] 
ubuntu@ubuntu:~$ 

Re: Sabnzbd won't start as a service on Ubuntu 11.04

Posted: August 4th, 2011, 4:42 am
by jcfp
sander wrote:First things first:
Make sure there is no SABnzbd running, otherwise the port is already in use.
Indeed. The init script wouldn't detect any running instance under another user account, or not running as a daemon.

If that doesn't help you:
oxseyn wrote:sudo cp ~/.sabnzbd/sabnzbd.ini /mnt/nas/sabnzbdplus/config.ini
So you copied a pre-existing config, and tried using that under a different account. Try moving it out of the way, its settings may be the problem. Also, what is the home dir of the sabnzbdplus user? The program would use that as a fallback if whatever is in the pre-existing ini doesn't work. That also means, if there is no home dir for that user, it has nowhere to go.
oxseyn wrote:sudo chown root:media -R /mnt/nas/sabnzbdplus
In addition, your setup hinges on group access to /mnt/nas/sabnzbdplus, which can be tricky. Both useradd and start-stop-daemon (used by the init script to start the application under the given account) may not behave as you expect when it comes to groups (see their man pages), thus making the directory structure inaccessible to sab.

In particular, I don't see an advantage to having root as the owner of those dirs. Since the naming suggests its for sab's exclusive use anyway, I would suggest making the sabnzbdplus user owner of /mnt/nas/sabnzbdplus, removing the pre-created structure in there, and possibly setting the group in /etc/default/sabnzbdplus as well (USER=user:group chown syntax, so USER=sabnzbdplus:media). Access for those in the media group and 'others' could be regulated via sab's permission setting on downloaded files.
oxseyn wrote:However, if I run it from my own account, it starts and runs just fine. When I browse to the website, I see it's using the configuration file from my directory, not the one specified in the /etc/default/sabnzbdplus file.
/etc/default/sabnzbdplus is the config file for the init script; the program is unaware of that file. Only the init script would read those settings and feed the appropriate command line options to the program.