Pause Sabnzbd when VPN is not connected

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
suzie123
Newbie
Newbie
Posts: 2
Joined: December 13th, 2012, 7:29 am

Pause Sabnzbd when VPN is not connected

Post by suzie123 »

Hi, I was hoping for a little help with this one.

I'm running xbmcbuntu, with Sabnzbd. I have openVPN configured through network-manager-openvpn.

Because i'm booting directly into XBMC I have no way to tell if my VPN is connected. To check I have to SSH in and run "curl ifconfig.me" and then go to whatsmyip.com and check the location. It's a pain, and defeats the purpose if my VPN drops.

I'm looking for a way to tell sabnzbd, via script, to pause if the Network Manager VPN is not connected.

Any ideas?

Many thanks... :D :D
User avatar
shypike
Administrator
Administrator
Posts: 19773
Joined: January 18th, 2008, 12:49 pm

Re: Pause Sabnzbd when VPN is not connected

Post by shypike »

The hard part is writing the script to determine the nextwork situation.
After that you can just use the "curl" tool to activate SABnzbd's API.
(See: http://wiki.sabnzbd.org/api )
User avatar
sander
Release Testers
Release Testers
Posts: 9429
Joined: January 22nd, 2008, 2:22 pm

Re: Pause Sabnzbd when VPN is not connected

Post by sander »

So you're running Ubuntu? Then I'll help you:

"curl ifconfig.me" seems enough to me; probably the two first bytes of the IP address are enough to determine whether the VPN is on or off. So IMHO you don't need to find out the exact location.

create a script / one-line to pause SABnzbd

create a script / one-line to unpause SABnzbd

Run it all each 5 minutes from crontab


If this approach is OK with you, I can help. As I like python and I dislike shell script, I would prefer just one python script with the above functionality.
suzie123
Newbie
Newbie
Posts: 2
Joined: December 13th, 2012, 7:29 am

Re: Pause Sabnzbd when VPN is not connected

Post by suzie123 »

Thanks to you both for your replies.

That sounds great, thanks sander.

I understand what the script needs to do, though am a complete noob when it comes to putting it together. So your offer is greatly appreciated.

In terms of python vs shell. It's all jazz to me.. haha.
User avatar
jcfp
Release Testers
Release Testers
Posts: 1032
Joined: February 7th, 2008, 12:45 pm

Re: Pause Sabnzbd when VPN is not connected

Post by jcfp »

shypike wrote:The hard part is writing the script to determine the nextwork situation.
Maybe that can be worked around by getting network-manager itself to run the script(s) at the correct times, along the lines of this.
User avatar
sander
Release Testers
Release Testers
Posts: 9429
Joined: January 22nd, 2008, 2:22 pm

Re: Pause Sabnzbd when VPN is not connected

Post by sander »

OK, first the public IP checker:

Can save the text below in a file sabonoff.py, and run it with "python sabonoff.py", and post the output here. Run it for both the VPN on and off.

Code: Select all

#!/bin/bin/python

ipurl = 'http://ifconfig.me/ip'

import urllib2
f = urllib2.urlopen(ipurl)
ipaddress = f.readline().rstrip()
(byte1,byte2,byte3,byte3)=ipaddress.split('.')
print byte1 + '.' + byte2
User avatar
sander
Release Testers
Release Testers
Posts: 9429
Joined: January 22nd, 2008, 2:22 pm

Re: Pause Sabnzbd when VPN is not connected

Post by sander »

No reaction from suzie123 ... I hate that.
Post Reply