Bug 153357 - [patch] news/sabnzbdplus: rc script fails to kill the process
Summary: [patch] news/sabnzbdplus: rc script fails to kill the process
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Matthias Andree
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-21 21:30 UTC by Damien Fleuriot
Modified: 2011-02-24 20:40 UTC (History)
0 users

See Also:


Attachments
sabnzbd.patch (794 bytes, patch)
2011-02-24 11:43 UTC, Damien Fleuriot
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Damien Fleuriot 2010-12-21 21:30:15 UTC
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.

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.
How-To-Repeat: This problem is repeatable all the time.
Comment 1 Damien Fleuriot 2011-02-24 11:14:54 UTC
Additional information:

I forgot to say, the newsgroup host I added points to a local stunnel
which in turn forwards requests to my actual newsgroups provider.

Thus the host I added for newsgroups is 127.0.0.1:119 , and that is
why the rc script's grep matches it, in addition to the host sabnzbd
runs on.
Comment 2 Damien Fleuriot 2011-02-24 11:43:59 UTC
Patch attached, to be run against the rc script

patch /usr/local/etc/rc.d/sabnzbd sabnzbd.patch
Comment 3 Matthias Andree freebsd_committer freebsd_triage 2011-02-24 12:05:42 UTC
Daniel,

please check <http://www.freebsd.org/cgi/query-pr.cgi?pr=153357> and
follow up with a message stating whether you approve of the proposed patch.

Thank you.

Best regards
Matthias Andree
Comment 4 Matthias Andree freebsd_committer freebsd_triage 2011-02-24 12:06:06 UTC
State Changed
From-To: open->feedback

waiting for maintainer feedback (approval/disapproval)
Comment 5 Matthias Andree freebsd_committer freebsd_triage 2011-02-24 20:01:52 UTC
Responsible Changed
From-To: freebsd-ports-bugs->mandree

I'll take it.
Comment 6 dfilter service freebsd_committer freebsd_triage 2011-02-24 20:18:35 UTC
mandree     2011-02-24 20:18:30 UTC

  FreeBSD ports repository

  Modified files:
    news/sabnzbdplus     Makefile 
    news/sabnzbdplus/files sabnzbd.in 
  Log:
  Only grep first host from .ini file in rcfile when shutting down.
  
  Submitted by: Damien Fleuriot <dam@c-mal.com>
  Approved by:  Daniel Bretoi <daniel@netwalk.org> (maintainer)
  PR:           ports/153357
  
  Revision  Changes    Path
  1.31      +1 -0      ports/news/sabnzbdplus/Makefile
  1.2       +1 -1      ports/news/sabnzbdplus/files/sabnzbd.in
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 7 Matthias Andree freebsd_committer freebsd_triage 2011-02-24 20:18:53 UTC
State Changed
From-To: feedback->closed

Committed. Thanks!
Comment 8 Matthias Andree freebsd_committer freebsd_triage 2011-02-24 20:35:43 UTC
-------- Original-Nachricht --------
Betreff: 	Re: ports/153357: [patch] news/sabnzbdplus: rc script fails to
kill the process
Datum: 	Thu, 24 Feb 2011 08:02:01 -0800
Von: 	Daniel <daniel@netwalk.org>
An: 	Matthias Andree <mandree@freebsd.org>



I approve

On Thu, Feb 24, 2011 at 4:05 AM, Matthias Andree <mandree@freebsd.org
<mailto:mandree@freebsd.org>> wrote:

     Daniel,

     please check <http://www.freebsd.org/cgi/query-pr.cgi?pr=153357> and
     follow up with a message stating whether you approve of the proposed
     patch.
[...]