Page 1 of 1

OpenVPN on Pi2 to start/stop sabnzbd?

Posted: February 22nd, 2015, 8:19 am
by piSAB
I've installed sabnzbd 0.7.20 on my Raspberry pi2 (Debian Wheezy) and it's performing very well.

It's starting up correctly on rebooting and stopping/starting and restarting when instructed to do so as a service correctly from the command line.

However, I also run an OpenVPN client on my pi2.

My aim here is to prevent sabnzbd from starting up automatically on rebooting and instead only instruct sabnzbd so start and to stop from within Openvpn's "route-up" and "down" switches.

Does anyone know how I can achieve this?

The command:
sudo update-rc.d -f transmission-daemon remove

Seems to successfully prevent sabnzbd from starting up automatically on rebooting but I'm still struggling to find the correct syntax to use within bash scripts (.sh files) referenced by the "route-up" and "down" switched to command sabnzbd to start and stop?

Any help offered would be very much appreciated.

Re: OpenVPN on Pi2 to start/stop sabnzbd?

Posted: February 25th, 2015, 8:31 am
by jcfp
You probably want to disable rather than remove the service, similar to the initial steps in https://forums.sabnzbd.org/viewtopic.php?f=16&t=6125 (except your shell commands would obviously be run from openvpn rather than rc.local)

With the service disabled it won't be autostarted on boot anymore but otherwise remains fully functional, i.e. the usual commands to manually start/stop the service will still work. Depending on the environment provided by openvpn you may have to use full paths such as /usr/sbin/service for your commands rather than just 'service' though.

Re: OpenVPN on Pi2 to start/stop sabnzbd?

Posted: February 26th, 2015, 6:36 am
by piSAB
Thank you very much JCFP for you reply and your helpful suggestions. I'm pleased also that you managed to understand my question despite my obvious typo:

sudo update-rc.d -f transmission-daemon remove
should have read
sudo update-rc.d -f sabnzbdplus remove


1) When I issued the command: sudo update-rc.d sabnzbdplus disable

to disable the service I received the following warnings in response

insserv: warning: current start runlevel(s) (empty) of script `sabnzbdplus' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `sabnzbdplus' overrides LSB defaults (0 1 6).

Are these warnings a cause for concern?

However as intended the service doesn't start up automatically on reboot and can be requested to Start/Stop/Restart successfully from the command line.

2)

Adding /etc/init.d/sabnzbdplus stop

to my openvpn scripts seems to correctly stop a running service, however

Adding /etc/init.d/sabnzbdplus start

results in the following being reported within my openvpn log file:

Starting SABnzbd+ binary newsgrabber:Traceback (most recent call last):
File "/usr/bin/sabnzbdplus", line 1873, in <module>
main()
File "/usr/bin/sabnzbdplus", line 1110, in main
sabnzbd.newsunpack.find_programs(sabnzbd.DIR_PROG)
File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 124, in find_programs
sabnzbd.newsunpack.PAR2_COMMAND = find_on_path('par2')
File "/usr/share/sabnzbdplus/sabnzbd/misc.py", line 1212, in find_on_path
paths = os.getenv('PATH').split(':')
AttributeError: 'NoneType' object has no attribute 'split'
failed!

Would you happen to know what I'm doing wrong here?

Re: OpenVPN on Pi2 to start/stop sabnzbd?

Posted: February 27th, 2015, 5:31 am
by jcfp
Looks like no PATH is defined by openvpn. Try using the /usr/sbin/service command rather than calling the init.d directly, or if that doesn't help define and export a sane PATH by adding something like this in your script before starting sab:

Code: Select all

PATH=/usr/sbin:/usr/bin:/sbin:/bin
export PATH
If necessary, you may even put that stuff in /etc/default/sabnzbdplus (on its own, not as part of any of the vars there).

Re: OpenVPN on Pi2 to start/stop sabnzbd?

Posted: March 3rd, 2015, 1:54 pm
by piSAB
Thanks again JCFP for your help.

It appears I was making things difficult for myself when all I needed were the usual "service sabnzbdplus start" and "service sabnzbdplus stop" commands.

Much appreciated.