Page 1 of 1

[SOLVED] SABnzbdplus / Shell question

Posted: 29 Dec 2014, 17:21
by Binkem
Hi all,

Today I found that SABnzbdplus was not running anymore on my B3. This may (or may not) be related to my restarting Apache2 last week.
When I tried to restart the service using the shell script:

Code: Select all

case "$1" in
start)
echo "Starting SABnzbd."
/usr/bin/sudo -u ###### -H /opt/SABnzbd-0.7.17/SABnzbd.py -d -f /home/######/.sabnzbd/sabnzbd.ini
;;
stop)
echo "Shutting down SABnzbd."
/usr/bin/wget -q --delete-after "http://localhost:8080/sabnzbd/api?mode=shutdown&apikey=############
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac

exit 0
I get the following error:
root@bubba:/home/martijn# /etc/init.d/sabnzbdplus stop
'etc/init.d/sabnzbdplus: line 1: syntax error near unexpected token `in
'etc/init.d/sabnzbdplus: line 1: `case "$1" in
I managed to start the service using the command in the script.

Can anyone explain why the script doesn't work? (It did work until now).

Martijn

Re: SABnzbdplus / Shell question

Posted: 30 Dec 2014, 03:22
by Ubi
just for fun, can you add the line

Code: Select all

#!/bin/bash
at the top of your script?

Also, is there any chance you edited this file in windows?

Re: SABnzbdplus / Shell question

Posted: 30 Dec 2014, 16:43
by Binkem
Hi Ubi,

Adding the line doesn't change anything.

I may have copied the script using the conTEXT editor on my Windows laptop. When saving after editing in Nano is states: File name to write [DOS Format]:

With some help from Google I managed to remove DOs-formatting (just press ALT-D when saving in Nano). Now it works again.

Thanks for the hints.

Martijn

Re: [SOLVED] SABnzbdplus / Shell question

Posted: 30 Dec 2014, 17:01
by Ubi
Ok, so the \r\n line endings did you in. Next time, run dos2unix on your file to remove these.

Oddly, you suggested that you did not alter the script (and it worked begore and not now), but now you mention that you did edit it in conTEXT. Thats a bit of a contradiction???

Re: [SOLVED] SABnzbdplus / Shell question

Posted: 30 Dec 2014, 17:09
by Gordon
Ah yes. If I would get a nickel for every time people told me they didn't change anything I'd be a very wealthy man indeed.

Re: [SOLVED] SABnzbdplus / Shell question

Posted: 30 Dec 2014, 17:28
by Ubi
Hey, if they always solved their own problems instead of creating them you'd be unemployed instead! :D

Re: [SOLVED] SABnzbdplus / Shell question

Posted: 30 Dec 2014, 17:37
by Binkem
Hi,

I remember that I started using ConTEXT because of the problems editing these files in Notepad gives. I had to do some maintenance to the file after updating SABnzbd to the current version. This may be what caught me out. I do seem to remember having the thing working after I copied it to /etc/init.d. Well it must be age kicking in :?

Thanks anyway.

Martijn