Date: Sat, 28 Aug 2010 16:17:39 GMT From: Spil <spil.oss@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/150070: Add rc.d script to sabnzbdplus Message-ID: <201008281617.o7SGHdk9001378@www.freebsd.org> Resent-Message-ID: <201008281620.o7SGK6Zh026007@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 150070 >Category: ports >Synopsis: Add rc.d script to sabnzbdplus >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Sat Aug 28 16:20:06 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Spil >Release: 8.1 >Organization: >Environment: FreeBSD build.example.org 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Wed Jul 21 06:55:14 CEST 2010 root@example.org:/usr/obj/usr/src/sys/FREEBSD81 i386 >Description: sabnzbdplus was lacking a rc.d script. Created one that cleanly shuts down the daemon using the parameters from the config file. Upgrades to 0.5.4 in the process. Good exercise, works for me and hope it's OK for the community! >How-To-Repeat: Not a problem >Fix: Patch attached with submission follows: diff -ruN sabnzbdplus.orig/Makefile sabnzbdplus/Makefile --- sabnzbdplus.orig/Makefile 2010-08-28 17:52:00.000000000 +0200 +++ sabnzbdplus/Makefile 2010-08-28 17:46:50.000000000 +0200 @@ -6,7 +6,7 @@ # PORTNAME= sabnzbdplus -PORTVERSION= 0.5.3 +PORTVERSION= 0.5.4 CATEGORIES= news MASTER_SITES= SF/${PORTNAME}/${PORTNAME}/sabnzbd-${PORTVERSION} DISTNAME= SABnzbd-${PORTVERSION}-src @@ -29,6 +29,8 @@ SUB_LIST+= PORTNAME=${PORTNAME} CONFLICTS= sabzndb-0.* +USE_RC_SUBR= sabnzbd + OPTIONS= PAR2CMDLINE "Required for postprocessing of par files." on \ UNRAR "Often required for unpacking many downloads." on \ FEEDPARSER "rss-feed support." on \ @@ -67,9 +69,11 @@ @${REINPLACE_CMD} -e "s:%%PREFIX%%:'${DATADIR}':g" \ ${WRKSRC}/SABnzbd.py + # the NO_BUILD option stops execution after configure. This should really be # post-build do-install: + @${REINPLACE_CMD} -e "s:%%PYTHON_CMD%%:${PYTHON_CMD}:g" work/sabnzbd ${INSTALL_SCRIPT} ${WRKSRC}/SABnzbd.py ${PREFIX}/bin/SABnzbd.py ${INSTALL} -d ${PYTHONPREFIX_SITELIBDIR}/ ${CP} -rp ${WRKSRC}/sabnzbd ${PYTHONPREFIX_SITELIBDIR}/ diff -ruN sabnzbdplus.orig/files/sabnzbd.in sabnzbdplus/files/sabnzbd.in --- sabnzbdplus.orig/files/sabnzbd.in 1970-01-01 01:00:00.000000000 +0100 +++ sabnzbdplus/files/sabnzbd.in 2010-08-28 18:09:58.000000000 +0200 @@ -0,0 +1,51 @@ +#!/bin/sh +# +# PROVIDE: sabnzbd +# REQUIRE: DAEMON +# +# Add the following lines to /etc/rc.conf to enable this service: +# +# sabnzbd_enable: Set to NO by default. Set it to YES to enable it. +# sabnzbd_conf_file: Directory where sabnzbd configuration +# data is stored. +# Default: /home/${sabnzbd-user}/.sabnzbd/sabnzbd.ini +# 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. +# + +. /etc/rc.subr + +name="sabnzbd" +rcvar=${name}_enable + +load_rc_config ${name} + +command=%%PREFIX%%/bin/SABnzbd.py +command_interpreter=%%PYTHON_CMD%% + +stop_precmd="${name}_prestop" + +: ${sabnzbd_enable:="NO"} +: ${sabnzbd_user:="sabnzbd"} +: ${sabnzbd_conf_file:="/home/${sabnzbd_user}/.sabnzbd/sabnzbd.ini"} + +sabnzbd_flags="\ + ${sabnzbd_conf_file:+-f ${sabnzbd_conf_file}} \ + --daemon ${sabnzbd_flags}" + +# SABnzbd can only be cleanly stopped by calling the http api +sabnzbd_prestop() +{ + apikey=`grep ^api_key ${sabnzbd_conf_file} | tr -d " _"` + host=`grep -E '^host\ =\ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' ${sabnzbd_conf_file} | tr -dc '[0-9].'` + if [ ${host} = "0.0.0.0" ] ; then host="localhost" ; fi + port=`grep -m1 ^port ${sabnzbd_conf_file} | tr -dc '[0-9]'` + echo "fetch http://$host:$port/api?mode=shutdown&$apikey" +} + +stop_command='fetch "http://${host}:${port}/api?mode=shutdown&${apikey}"' + +run_rc_command "$1" + >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008281617.o7SGHdk9001378>