diff options
author | Steve Wills <swills@FreeBSD.org> | 2010-10-10 18:02:07 +0000 |
---|---|---|
committer | Steve Wills <swills@FreeBSD.org> | 2010-10-10 18:02:07 +0000 |
commit | 0ba0e37fd3c33287ddacc30b6a17259ad7759ec0 (patch) | |
tree | c1c0a6bd27f965567b1dcdb6d955777d443eee2c /news/sabnzbdplus | |
parent | ae0c801b4167e98d341ada5610dea0af093cf1b9 (diff) | |
download | ports-0ba0e37fd3c33287ddacc30b6a17259ad7759ec0.tar.gz ports-0ba0e37fd3c33287ddacc30b6a17259ad7759ec0.zip |
Notes
Diffstat (limited to 'news/sabnzbdplus')
-rw-r--r-- | news/sabnzbdplus/Makefile | 10 | ||||
-rw-r--r-- | news/sabnzbdplus/files/pkg-message.in | 21 | ||||
-rw-r--r-- | news/sabnzbdplus/files/sabnzbd.in | 77 | ||||
-rw-r--r-- | news/sabnzbdplus/pkg-plist | 2 |
4 files changed, 109 insertions, 1 deletions
diff --git a/news/sabnzbdplus/Makefile b/news/sabnzbdplus/Makefile index 9b5eca2bb9ba..ab546ec44fc1 100644 --- a/news/sabnzbdplus/Makefile +++ b/news/sabnzbdplus/Makefile @@ -7,7 +7,7 @@ PORTNAME= sabnzbdplus PORTVERSION= 0.5.4 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= news MASTER_SITES= SF/${PORTNAME}/${PORTNAME}/sabnzbd-${PORTVERSION} DISTNAME= SABnzbd-${PORTVERSION}-src @@ -27,8 +27,13 @@ NO_BUILD= yes WRKSRC= ${WRKDIR}/SABnzbd-${PORTVERSION} PLIST_SUB= PORTNAME=${PORTNAME} SUB_LIST+= PORTNAME=${PORTNAME} +SUB_FILES= pkg-message +USE_RC_SUBR= sabnzbd CONFLICTS= sabzndb-0.* +USERS= _sabnzbd +GROUPS= _sabnzbd + OPTIONS= PAR2CMDLINE "Required for postprocessing of par files." on \ UNRAR "Often required for unpacking many downloads." on \ FEEDPARSER "rss-feed support." on \ @@ -90,5 +95,8 @@ post-install: ${CP} ${WRKSRC}/$i ${DOCSDIR} .endfor .endif + ${MKDIR} ${PREFIX}/sabnzbd + ${CHOWN} _sabnzbd:_sabnzbd ${PREFIX}/sabnzbd + @${CAT} ${WRKDIR}/pkg-message .include <bsd.port.post.mk> diff --git a/news/sabnzbdplus/files/pkg-message.in b/news/sabnzbdplus/files/pkg-message.in new file mode 100644 index 000000000000..36afbd3a9f96 --- /dev/null +++ b/news/sabnzbdplus/files/pkg-message.in @@ -0,0 +1,21 @@ +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +This port now includes an rc script: + +%%PREFIX%%/etc/rc.d/sabnzbd + +Add: + +sabnzbd_enable="YES" + +to /etc/rc.conf, then start it via: + +%%PREFIX%%/etc/rc.d/sabnzbd start + +Once started, visit: + +http://localhost:8080/sabnzbd/ + +to configure. + +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * diff --git a/news/sabnzbdplus/files/sabnzbd.in b/news/sabnzbdplus/files/sabnzbd.in new file mode 100644 index 000000000000..33abe11cbed6 --- /dev/null +++ b/news/sabnzbdplus/files/sabnzbd.in @@ -0,0 +1,77 @@ +#!/bin/sh +# +# PROVIDE: sabnzbd +# KEYWORD: shutdown +# +# Add the following lines to /etc/rc.conf.local or /etc/rc.conf +# to enable this service: +# +# sabnzbd_enable (bool): Set to NO by default. +# Set it to YES to enable it. +# sabnzbd_conf_dir: Directory where sabnzbd configuration +# data is stored. +# Default: %%PREFIX%%/sabnzbd +# sabnzbd_user: The user account sabnzbd daemon runs as what +# you want it to be. It uses '_sabnzbd' user by +# default. Do not sets it as empty or it will run +# as root. +# sabnzbd_group: The group account sabnzbd daemon runs as what +# you want it to be. It uses '_sabnzbd' group by +# default. Do not sets it as empty or it will run +# as wheel. + +. /etc/rc.subr + +name="sabnzbd" +rcvar=${name}_enable + +load_rc_config ${name} + +: ${sabnzbd_enable:="NO"} +: ${sabnzbd_user:="_sabnzbd"} +: ${sabnzbd_group:="_sabnzbd"} +: ${sabnzbd_conf_dir:="%%PREFIX%%/sabnzbd"} + +required_dirs=${sabnzbd_conf_dir} + +status_cmd="${name}_status" +stop_cmd="${name}_stop" +start_precmd=sabnzbd_check_dir + +command="/usr/sbin/daemon" +command_args="-f %%PREFIX%%/bin/SABnzbd.py ${sabnzbd_flags} --daemon -b 0 -w 0 -l 0 -f ${sabnzbd_conf_dir}" + +# SABnzbd can only be cleanly stopped by calling the http api +sabnzbd_stop() { + echo "Stopping $name" + if [ -f "${sabnzbd_conf_dir}/sabnzbd.ini" ]; then + apikey=`grep ^api_key ${sabnzbd_conf_dir}/sabnzbd.ini | tr -d " _"` + host=`grep -E '^host\ =\ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' ${sabnzbd_conf_dir}/sabnzbd.ini | tr -dc '[0-9].'` + if [ ${host} = "0.0.0.0" ] ; then host="localhost" ; fi + port=`grep -m1 ^port ${sabnzbd_conf_dir}/sabnzbd.ini | tr -dc '[0-9]'` + fetch -o /dev/null "http://${host}:${port}/api?mode=shutdown&${apikey}" > /dev/null 2>&1 + else + sabnzbd_pid=`ps -U ${sabnzbd_user} | grep "python.*SABnzbd.py.*--daemon" | grep -v 'grep' | awk '{print $1}'` + if [ -n "${sabnzbd_pid}" ]; then + kill ${sabnzbd_pid} + fi + fi +} + +sabnzbd_status() { + sabnzbd_pid=`ps -U ${sabnzbd_user} | grep "python.*SABnzbd.py.*--daemon" | grep -v 'grep' | awk '{print $1}'` + if [ -n "${sabnzbd_pid}" ]; then + echo "$name is running as ${sabnzbd_pid}" + else + echo "$name is not running" + fi +} + +sabnzbd_check_dir() { + if [ ! -f "${required_dirs}" -a ! -d "${required_dirs}" -a ! -L "${required_dirs}" ]; then + mkdir -p ${required_dirs} + chown ${sabnzbd_user}:${sabnzbd_group} ${required_dirs} + fi +} + +run_rc_command "$1" diff --git a/news/sabnzbdplus/pkg-plist b/news/sabnzbdplus/pkg-plist index 6e49a7d0a513..ea3a81a48069 100644 --- a/news/sabnzbdplus/pkg-plist +++ b/news/sabnzbdplus/pkg-plist @@ -322,3 +322,5 @@ bin/SABnzbd.py @dirrm share/sabnzbdplus/interfaces @dirrm share/sabnzbdplus/language @dirrm share/sabnzbdplus +@dirrmtry sabnzbd +@stopdaemon sabnzbd |