From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Aug 28 16:20:07 2010 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6096810656A6 for ; Sat, 28 Aug 2010 16:20:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 20BC18FC1E for ; Sat, 28 Aug 2010 16:20:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o7SGK6qY026008 for ; Sat, 28 Aug 2010 16:20:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o7SGK6Zh026007; Sat, 28 Aug 2010 16:20:06 GMT (envelope-from gnats) Resent-Date: Sat, 28 Aug 2010 16:20:06 GMT Resent-Message-Id: <201008281620.o7SGK6Zh026007@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Spil Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47C7D10656A5 for ; Sat, 28 Aug 2010 16:17:40 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 376518FC13 for ; Sat, 28 Aug 2010 16:17:40 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o7SGHdbp001379 for ; Sat, 28 Aug 2010 16:17:40 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o7SGHdk9001378; Sat, 28 Aug 2010 16:17:39 GMT (envelope-from nobody) Message-Id: <201008281617.o7SGHdk9001378@www.freebsd.org> Date: Sat, 28 Aug 2010 16:17:39 GMT From: Spil To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/150070: Add rc.d script to sabnzbdplus X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2010 16:20:07 -0000 >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: