First is to install rTorrent and screen if you don't already have them:
~$ sudo apt-get install rtorrent screen
Once installed, you'll want to setup your rtorrent settings and ensure they work as expected before continuing (read more).
Next comes the upstart job script. Here's what I use:
description "ncurses BitTorrent client based on LibTorrent"
start on (local-filesystems and net-device-up and runlevel [2345])
stop on runlevel [016]
chdir /home/user
pre-start exec su user -c "mkdir -p .rtorrent/session"
script
su user -c "screen -d -m -S rtorrent rtorrent"
end script
Replace each instance of user with your Ubuntu username. Save to /etc/init/rtorrent.conf and you're done. rTorrent should automatically start on subsequent system startups.
Update: Changed upstart script to automatically create session folder if it doesn't exist.
Viewing rTorrent's status
Since rTorrent is running in a detached screen process, you can view what's going on and basically use rTorrent by attaching to the process:
~$ screen -r rtorrent
To detach again, press Ctrl-a followed by d.
That's it . Enjoy!
For some reason rtorrent not picking up .rtorrent.rc which in my home dir if i start this way.
ReplyDeleteWorks for me here. Did you remember to replace "user" in the upstart script with your username?
DeleteTested on Ubuntu 12.04 64-bit which never had rTorrent installed after a clean install.
Does this track the pid so I can stop and restart the service? I have nearly the same script and I'm not able to do those.
ReplyDeleteI'm not sure what you mean by "track the pid". AFAIK there's no need to do so.
DeleteI think the answers here should be what you're looking for though: http://askubuntu.com/questions/19320/whats-the-recommended-way-to-enable-disable-services