Deluged running from boot?

Second question, but unrelated enough from the other than hopefully it needs a new topic.

I have installed and configured deluged with a thin client which is working well, but I’d like to have it start on boot.

I’ve read around the 'web about upstart scripts, but have no idea where to begin. I would have thought a single line in the right config file would work.

I also tried enabling it as a service, which was suggested by somebody on IRC. Although the command didn’t error, deluged was not started automatically on next boot.

Any help very much appreciated!

Our beloved /etc/inittab is no more. Instead, we have a /etc/systemd/system/ directory chock-full of symlinks to files in /usr/lib/systemd/system/. /usr/lib/systemd/system/ contains init scripts; to start a service at boot it must be linked to /etc/systemd/system/. The systemctl command does this for you when you enable a new service, like this example...

http://www.linux.com/learn/tutorials/788613-understanding-and-using-systemd

For a simple command run at boot without going to all the trouble of defining a service, you could use an entry in /etc/rc.local.

My rc.local now looks like this:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
deluged
exit 0

But that doesn’t bring deluge up on boot either.

I must be missing something obvious!

edit: In fact, when I try to load deluged I get the following:

osmc@osmc:~$ deluged
osmc@osmc:~$ [ERROR ] 09:49:04 rpcserver:376 Couldn’t listen on any:58846: [Errno 98] Address already in use.

I’m guessing it must be because the rc.local file isn’t calling it for the user osmc?

Make sure you include the full path to the executable as early boot scripts do not have the same path as a console/ssh login session.

Also keep in mind it will be run as root - if you need to run it as the osmc user you might need something like:

sudo -u osmc /full/path/to/deluged

I have sorted it with the following command:

su - osmc -c “deluged &”

Seems to work well.