Working Gentoo Ebuild for sabnzbd-0.4.2
Posted: April 19th, 2008, 4:32 pm
(EDIT: I have a working ebuild, see my post below about it.)
[updated to shutdown properly (using curl and /sabnzbd/shutdown)]
Figured this might help someone down the line:
Working with what rullerz built for .25/.27 a looonng time ago, I was able to get some simple conf.d/init.d scripts and running under another user and working almost as nicely as the .27 ebuild had things for .4beta2.
contents of /etc/init.d/sabnzbd+ (put the plus in so it doesn't break my old .27 install)
contents of /etc/conf.d/sabnzbd+
* I made a user/group called sabnzbd:sabnzbd, put the user's home in /var/lib/SABnzbd+ with nologin shell.
* Copied SABnzbd-0.4.0Beta2 to /var/lib/SABnzbd+/.SABnzbd-0.4.0Beta2.
* symlinked /var/lib/SABnzbd+/sabnzbd -> /var/lib/SABnzbd+/.SABnzbd-0.4.0Beta2
* copied a .sabnzbd folder from my user dir (from running regularly) to /var/lib/SABnzbd+/.sabnzbd
* symlinked both {/var/lib/SABnzbd+/.sabnzbd/sabnzbd.ini, /var/lib/SABnzbd+/sabnzbd/sabnzbd.ini} -> /etc/SABnzbd+.conf (read the notes in the conf.d file as to how the -f flag didn't seem to work, one of these links are probably not needed, i'll look into it later)
* chown -R sabnzbd:sabnzbd /var/lib/SABnzbd+
* set permissions to your specifications on /etc/SABnzbd+.conf (i choose sabnzbd:sabnzbd w/ 660 mask, you may prefer 600)
From there, run and cross your fingers (don't forget execute permission for that file)
if you would like this to run at startup:
I think that since things flow as smoothly as they have been with upgrades, upgrading should be as easy as clearing the queue/history, copying the new install to /var/lib/SABnzbd+ and modifying the smylink to point to the new install.
I may be working on an ebuild down the road; but, it works for me now and i'm a little strapped on spare time with finals coming up. Maybe I'll write one for 0.4.0 final.
Things to consider:
I just decided to throw this in /var/lib to be consistent with the other "services" on this box. It may be more appropriate to place it in /opt as this install is done w/o the package manager and could break things down the line. I did something very similar with azureus bittorrent client using the WebUI plugin so that's something to keep in mind if you still BTorrent.
Enjoy!
[updated to shutdown properly (using curl and /sabnzbd/shutdown)]
Figured this might help someone down the line:
Working with what rullerz built for .25/.27 a looonng time ago, I was able to get some simple conf.d/init.d scripts and running under another user and working almost as nicely as the .27 ebuild had things for .4beta2.
contents of /etc/init.d/sabnzbd+ (put the plus in so it doesn't break my old .27 install)
Code: Select all
#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
opts="start stop"
depend() {
need net
}
start() {
ebegin "Starting SABnzbd+"
if ! check_config ; then
eend 1
return 1
fi
start-stop-daemon --quiet --start -c ${SAB_USER}:${SAB_GROUP} \
--exec /var/lib/SABnzbd+/sabnzbd/SABnzbd.py -- -s ${SAB_HOSTNAME}:${SAB_PORT} -d &> /dev/null
eend $?
}
stop() {
ebegin "Stopping SABnzbd+"
curl -s http://${SAB_HOSTNAME}:${SAB_PORT}/sabnzbd/shutdown > /dev/null
eend $?
}
check_config() {
if [ ! -e ${SAB_CONFIGFILE} ] ; then
eerror "ERROR: can't find ${SAB_CONFIGFILE}."
return 1
else
return 0
fi
}
Code: Select all
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# /etc/conf.d/sabnzbd+
# Config file for sabnzbd+ init script
# Which user to run sabnzbd as (make sure the user exists on your system)
SAB_USER="sabnzbd"
SAB_GROUP="sabnzbd"
# What hostname and port should sabnzbd+ listen on? (I'm assuming ${HOSTNAME} returns something useful on your network)
SAB_HOSTNAME=${HOSTNAME}
SAB_PORT="8080"
# Location of config file.
# Make sure the user specified above can read this file.
#this feature doesn't work right now, just change the symbolic link in
# /var/lib/SABnzbd+/.sabnzbd/sabnzbd.ini -> ?
#(with this feature enabled and used, it throws weird "cannot write to log" errors)
#SAB_CONFIGFILE="/etc/SABnzbd+.conf"
* Copied SABnzbd-0.4.0Beta2 to /var/lib/SABnzbd+/.SABnzbd-0.4.0Beta2.
* symlinked /var/lib/SABnzbd+/sabnzbd -> /var/lib/SABnzbd+/.SABnzbd-0.4.0Beta2
* copied a .sabnzbd folder from my user dir (from running regularly) to /var/lib/SABnzbd+/.sabnzbd
* symlinked both {/var/lib/SABnzbd+/.sabnzbd/sabnzbd.ini, /var/lib/SABnzbd+/sabnzbd/sabnzbd.ini} -> /etc/SABnzbd+.conf (read the notes in the conf.d file as to how the -f flag didn't seem to work, one of these links are probably not needed, i'll look into it later)
* chown -R sabnzbd:sabnzbd /var/lib/SABnzbd+
* set permissions to your specifications on /etc/SABnzbd+.conf (i choose sabnzbd:sabnzbd w/ 660 mask, you may prefer 600)
From there, run
Code: Select all
/etc/init.d/sabnzbd+ start
if you would like this to run at startup:
Code: Select all
rc-update add sabnzbd+ default
I may be working on an ebuild down the road; but, it works for me now and i'm a little strapped on spare time with finals coming up. Maybe I'll write one for 0.4.0 final.
Things to consider:
I just decided to throw this in /var/lib to be consistent with the other "services" on this box. It may be more appropriate to place it in /opt as this install is done w/o the package manager and could break things down the line. I did something very similar with azureus bittorrent client using the WebUI plugin so that's something to keep in mind if you still BTorrent.
Enjoy!