Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Dec 2010 21:29:58 GMT
From:      Damien Fleuriot <dam@c-mal.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/153357: [patch] sabnzbd rc script fails to kill the process
Message-ID:  <201012212129.oBLLTwdo076127@red.freebsd.org>
Resent-Message-ID: <201012212130.oBLLUFPM074656@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         153357
>Category:       ports
>Synopsis:       [patch] sabnzbd rc script fails to kill the process
>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:   Tue Dec 21 21:30:15 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Damien Fleuriot
>Release:        7.4
>Organization:
>Environment:
FreeBSD ks306450.kimsufi.com 7.4-PRERELEASE FreeBSD 7.4-PRERELEASE #2: Fri Dec 17 12:26:28 CET 2010     root@ks306450.kimsufi.com:/usr/obj/usr/src/sys/OVH  amd64
>Description:
The rc script for sabnzbd fails to stop the process.



See, I added a newsgroups host, which was added to sabnzbd.ini


The stop command in the rc.d script uses grep to find what host to send the stop command to (it uses the web interface to shutdown sabnzbd):
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].'`


The problem is, now that I added a newsgroups host, grep matches it too.

Which gives me a $host variable with: "127.0.0.1" (interface sabnzbd binds to) AND again "yourdummyngprovider.com" (the newsgroups host) for a grand total of:
$host="127.0.0.1yourdummyngprovider.com"

In turn, the stop command then tries to curl to:
http://127.0.0.1yourdummyngprovider.com:8080/api?mode=shutdown&apikey=yourapikeyhere

This will never work.

>How-To-Repeat:
This problem is repeatable all the time.
>Fix:
I suggest changing the grep command from:
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].'`
to
host=`grep -E -m1 '^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].'`

-m1 ensures grep stops after 1 match, which is what we want.


Notice this is already done to determine what port the sabnzbd daemon is listening on:
port=`grep -m1 ^port ${sabnzbd_conf_dir}/sabnzbd.ini | tr -dc '[0-9]'`

I have made this change to the rc script on my box and it works fine.


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012212129.oBLLTwdo076127>