aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Wills <swills@FreeBSD.org>2010-10-10 18:02:07 +0000
committerSteve Wills <swills@FreeBSD.org>2010-10-10 18:02:07 +0000
commit0ba0e37fd3c33287ddacc30b6a17259ad7759ec0 (patch)
treec1c0a6bd27f965567b1dcdb6d955777d443eee2c
parentae0c801b4167e98d341ada5610dea0af093cf1b9 (diff)
downloadports-0ba0e37fd3c33287ddacc30b6a17259ad7759ec0.tar.gz
ports-0ba0e37fd3c33287ddacc30b6a17259ad7759ec0.zip
- add RC script
- add separate UIDs/GIDs for the daemon - bump PORTREVSION PR: ports/150070 Submitted by: Spil <spil.oss@gmail.com> Approved by: pgollucci (mentor), daniel@netwalk.org (maintainer)
Notes
Notes: svn path=/head/; revision=262769
-rw-r--r--GIDs1
-rw-r--r--UIDs1
-rw-r--r--news/sabnzbdplus/Makefile10
-rw-r--r--news/sabnzbdplus/files/pkg-message.in21
-rw-r--r--news/sabnzbdplus/files/sabnzbd.in77
-rw-r--r--news/sabnzbdplus/pkg-plist2
6 files changed, 111 insertions, 1 deletions
diff --git a/GIDs b/GIDs
index e482f7b1bdeb..c7d89ccffe70 100644
--- a/GIDs
+++ b/GIDs
@@ -113,6 +113,7 @@ dkfilter:*:325:
wildfire:*:340:
stunnel:*:341:
openfire:*:342:
+_sabnzbd:*:350:
_iodined:*:353:
httptunnel:*:361:
ldap:*:389:
diff --git a/UIDs b/UIDs
index af78cb5ef0df..b7a1c8f6ea79 100644
--- a/UIDs
+++ b/UIDs
@@ -123,6 +123,7 @@ _pma:*:336:80::0:0:phpMyAdmin Owner:/nonexistent:/usr/sbin/nologin
wildfire:*:340:340::0:0:Wildfire Daemon:/nonexistent:/usr/sbin/nologin
stunnel:*:341:341::0:0:Stunnel Daemon:/nonexistent:/usr/sbin/nologin
openfire:*:342:342::0:0:Openfire IM Daemon:/nonexistent:/usr/sbin/nologin
+_sabnzbd:*:350:350::0:0:sabnzb Daemon:/nonexistent:/usr/sbin/nologin
_iodined:*:353:353::0:0:Iodine Daemon:/nonexistent:/usr/sbin/nologin
httptunnel:*:361:361::0:0:httptunnel Daemon:/nonexistent:/usr/sbin/nologin
ldap:*:389:389::0:0:OpenLDAP Server:/nonexistent:/usr/sbin/nologin
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