From d632cee68fd03ddc1897a8e4e371829a8ebbd383 Mon Sep 17 00:00:00 2001 From: Mike Staszel Date: Tue, 14 Sep 2010 04:47:33 +0000 Subject: [PATCH] Added sabnzbd to community from AUR --- community/sabnzbd/PKGBUILD | 39 ++++++++++++++++++++++++++++ community/sabnzbd/addnzb.sh | 13 ++++++++++ community/sabnzbd/sabnzbd | 3 +++ community/sabnzbd/sabnzbd.confd | 16 ++++++++++++ community/sabnzbd/sabnzbd.desktop | 9 +++++++ community/sabnzbd/sabnzbd.init | 43 +++++++++++++++++++++++++++++++ community/sabnzbd/sabnzbd.install | 24 +++++++++++++++++ community/sabnzbd/x-nzb.xml | 10 +++++++ 8 files changed, 157 insertions(+) create mode 100644 community/sabnzbd/PKGBUILD create mode 100644 community/sabnzbd/addnzb.sh create mode 100644 community/sabnzbd/sabnzbd create mode 100644 community/sabnzbd/sabnzbd.confd create mode 100644 community/sabnzbd/sabnzbd.desktop create mode 100644 community/sabnzbd/sabnzbd.init create mode 100644 community/sabnzbd/sabnzbd.install create mode 100644 community/sabnzbd/x-nzb.xml diff --git a/community/sabnzbd/PKGBUILD b/community/sabnzbd/PKGBUILD new file mode 100644 index 000000000..351006ae4 --- /dev/null +++ b/community/sabnzbd/PKGBUILD @@ -0,0 +1,39 @@ +# No Plugbox changes, this is just from AUR but has been requested +# very, very often. + +pkgname=sabnzbd +pkgver=0.5.4 +pkgrel=3 +pkgdesc="A web-interface based binary newsgrabber with NZB file support" +arch=(i686 x86_64) +url="http://www.sabnzbd.org/" +license=('GPL') +depends=('par2cmdline' 'python' 'python-cheetah' 'python-feedparser' 'python-yenc' 'pyopenssl' 'unrar' 'unzip' 'sqlite3' 'curl') +install=sabnzbd.install +backup=('etc/conf.d/sabnzbd' 'opt/sabnzbd/sabnzbd.ini') +source=("http://downloads.sourceforge.net/sabnzbdplus/SABnzbd-$pkgver-src.tar.gz" +sabnzbd sabnzbd.init sabnzbd.confd sabnzbd.desktop x-nzb.xml addnzb.sh) + +md5sums=('b64e5d47ea4c115b98dd96744946c89d' + 'f45907d98a19052eaeb7ad98ff13b16d' + '0300f4804c7abcfc7013b3a90b83c38c' + 'dc5fdcc132033b38e2f34d2355d573be' + 'a83d735a8a21b68622ed0d6ac1139a9e' + '11fb2cd1451e3725b08bfc2bd045be54' + '3287c7a1becdf0a4f7276cfbccb301dd') + +build() { + mkdir -p $startdir/pkg/opt/sabnzbd + touch $startdir/pkg/opt/sabnzbd/sabnzbd.ini + mv -v $startdir/src/SABnzbd-$pkgver/* $startdir/pkg/opt/sabnzbd/ + find $startdir/pkg/opt/sabnzbd -type d -exec chmod 755 {} \; + find $startdir/pkg/opt/sabnzbd -type f -exec chmod 644 {} \; + chmod 755 $startdir/pkg/opt/sabnzbd/SABnzbd.py + chmod 755 $startdir/pkg/opt/sabnzbd/Sample-PostProc.sh + install -D -m755 $startdir/sabnzbd $startdir/pkg/usr/bin/sabnzbd + install -D -m755 $startdir/sabnzbd.init $startdir/pkg/etc/rc.d/sabnzbd + install -D -m644 $startdir/sabnzbd.confd $startdir/pkg/etc/conf.d/sabnzbd + install -D -m755 $startdir/sabnzbd.desktop $startdir/pkg/usr/share/applications/sabnzbd.desktop + install -D -m755 $startdir/addnzb.sh $startdir/pkg/opt/sabnzbd/addnzb.ssh + install -D -m770 $startdir/x-nzb.xml $startdir/pkg/opt/sabnzbd/x-nzb.xml +} diff --git a/community/sabnzbd/addnzb.sh b/community/sabnzbd/addnzb.sh new file mode 100644 index 000000000..4282cba98 --- /dev/null +++ b/community/sabnzbd/addnzb.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +. /etc/conf.d/sabnzbd + +# SABnzbd must be able to read the file, so we copy it to a directory where it +# certainly has rights. +nzbname=`basename $1` +TEMP_NZB="/var/tmp/"$nzbname + +cp $1 $TEMP_NZB +curl -f "$SABNZBD_PROTOCOL://$SABNZBD_USPW$SABNZBD_IP:$SABNZBD_PORT/sabnzbd/api?mode=addlocalfile&name=$TEMP_NZB&pp=1&priority=-1&apikey=$SABNZBD_KEY" +rm $TEMP_NZB +exit 0 diff --git a/community/sabnzbd/sabnzbd b/community/sabnzbd/sabnzbd new file mode 100644 index 000000000..bc3372a2c --- /dev/null +++ b/community/sabnzbd/sabnzbd @@ -0,0 +1,3 @@ +#!/bin/sh + +python /opt/sabnzbd/SABnzbd.py -f $HOME/.sabnzbd.ini "$@" diff --git a/community/sabnzbd/sabnzbd.confd b/community/sabnzbd/sabnzbd.confd new file mode 100644 index 000000000..27ebddf46 --- /dev/null +++ b/community/sabnzbd/sabnzbd.confd @@ -0,0 +1,16 @@ +SABNZBD_USER="sabnzbd" +SABNZBD_CONF="/opt/sabnzbd/sabnzbd.ini" + +# Put the session key from Config > General here +SABNZBD_KEY="" + +# Set to the protocol, IP and port +SABNZBD_PROTOCOL="http" +SABNZBD_IP="127.0.0.1" +SABNZBD_PORT="8080" + +# If you use a username and password, change the following variable to +# "user:pass@" +SABNZBD_USPW="" + + diff --git a/community/sabnzbd/sabnzbd.desktop b/community/sabnzbd/sabnzbd.desktop new file mode 100644 index 000000000..dd989834f --- /dev/null +++ b/community/sabnzbd/sabnzbd.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Version=1.0 +Name=SABnzbd+ +GenericName=Binary Newsreader +Exec=sh /opt/sabnzbd/addnzb.sh %u +Terminal=false +Categories=Network +MimeType=application/x-nzb diff --git a/community/sabnzbd/sabnzbd.init b/community/sabnzbd/sabnzbd.init new file mode 100644 index 000000000..0c36d3161 --- /dev/null +++ b/community/sabnzbd/sabnzbd.init @@ -0,0 +1,43 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions +. /etc/conf.d/sabnzbd + +case "$1" in + start) + stat_busy "Starting SABnzbd" + + if [ -f /var/run/daemons/sabnzbd ]; then + echo -n "Sabnzbd is already running as a daemon! If you are certain it is not running, remove /var/run/daemons/sabnzbd." + stat_fail + else + su - $SABNZBD_USER -c "python /opt/sabnzbd/SABnzbd.py -f $SABNZBD_CONF -s $SABNZBD_IP:$SABNZBD_PORT -d" -s /bin/sh + if [ $? -gt 0 ]; then + stat_fail + else + add_daemon sabnzbd + stat_done + fi + fi + ;; + stop) + stat_busy "Stopping SABnzbd" + + curl -f "$SABNZBD_PROTOCOL://$SABNZBD_USPW$SABNZBD_IP:$SABNZBD_PORT/sabnzbd/api?mode=shutdown&apikey=$SABNZBD_KEY" &> /dev/null + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon sabnzbd + stat_done + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac +exit 0 diff --git a/community/sabnzbd/sabnzbd.install b/community/sabnzbd/sabnzbd.install new file mode 100644 index 000000000..cda40267a --- /dev/null +++ b/community/sabnzbd/sabnzbd.install @@ -0,0 +1,24 @@ +## arg 1: the new package version +post_install() { + # add x-nzb mimetype + xdg-mime install --mode system /opt/sabnzbd/x-nzb.xml + + groupadd sabnzbd &> /dev/null + useradd -g sabnzbd -d /opt/sabnzbd -s /bin/false sabnzbd &> /dev/null + chown -R sabnzbd:sabnzbd /opt/sabnzbd + echo " >> Don't forget to edit /etc/conf.d/sabnzbd!" + echo " >> Add your Session key and if necessary your username and password to ensure a proper shutdown." + echo " >> " + echo " >> If you want to associate .nzb-files with SABnzbd, run 'xdg-mime default sabnzbd.desktop applications/x-nzb'" + +} +## arg 1: the new package version +## arg 2: the old package version +post_upgrade() { + chown -R sabnzbd:sabnzbd /opt/sabnzbd +} + +## arg 1: the old package version +pre_remove() { + userdel sabnzbd &> /dev/null +} diff --git a/community/sabnzbd/x-nzb.xml b/community/sabnzbd/x-nzb.xml new file mode 100644 index 000000000..e77d28410 --- /dev/null +++ b/community/sabnzbd/x-nzb.xml @@ -0,0 +1,10 @@ + + + + + An XML-based file format for retrieving posts from NNTP (Usenet) servers + + + + +