ports/153357: [patch] sabnzbd rc script fails to kill the process

Damien Fleuriot dam at c-mal.com
Tue Dec 21 21:30:16 UTC 2010


>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 at 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:



More information about the freebsd-ports-bugs mailing list