Hi,
I am using a vpn. I'm not always sure if i am connected to my vpn. Under status and interface options however i can view the public ip adress, but i'm not always at home to reset my vpn connection or able to notice the public ip adress when my (automated) downloads starts.
Is it possible to implement a solution where i can enter an public ip adress (or partial public ip adress) that is checked when downloading? (If possible combined with a time interval how often the public ip adress check should take place?) If the current public (partial) ip adress is not the same as the entered public (partial) ip adress the downloads go into pause-state and send a warning?
Sometimes my vpn drops out and comes back up after a certain time, so it would be perfect if the ip adress check would be continued in pause state, in the case my vpn connection comes back up, the download will automatically be resumed.
Thanks in advance!
pause download if not connected to acertain public ip-adress
Re: pause download if not connected to acertain public ip-ad
If the VPN IP address is always the same, you could try filling out that IP address as "SABnzbd Host" under General. Warning: dangerous stuff as SABnzbd won't start if the IP address is not there.
If you are on Linux, a script of few lines can take care of what you want in a more safe way.
If you are on Linux, a script of few lines can take care of what you want in a more safe way.
Re: pause download if not connected to acertain public ip-ad
Sander,
VPN is not always the same, i travell a lot ;-)
I am on linux, but know very little about scripting. So some help would be much appreciated!. I assume the script must be adressed as a pre queue userscript (which leaves the problem of vpn dropping out in the midst of a download or greater already queued list of downloads) or is there another way/place to call such a script?
Grtz,
Najrad
VPN is not always the same, i travell a lot ;-)
I am on linux, but know very little about scripting. So some help would be much appreciated!. I assume the script must be adressed as a pre queue userscript (which leaves the problem of vpn dropping out in the midst of a download or greater already queued list of downloads) or is there another way/place to call such a script?
Grtz,
Najrad
Re: pause download if not connected to acertain public ip-ad
Run this on your Linux:
It will show your public IPv4 address:
If you want to check if it starts with ... let's says ... "45.71.", run this:
Fill that out with the VPN address range start. Does that work for you?
If so, we can proceed.
Code: Select all
curl -s -4 http://self-test.sabnzbd.org/
If you want to check if it starts with ... let's says ... "45.71.", run this:
Code: Select all
curl -s -4 http://self-test.sabnzbd.org/ | grep -e "^45.71" > /dev/null && echo "yes" || echo "no"
If so, we can proceed.
Re: pause download if not connected to acertain public ip-ad
Sander,
This works for me, let's proceed!
This works for me, let's proceed!
Re: pause download if not connected to acertain public ip-ad
And do you understand what that line does?
If so, proceed:
Fill out your own API-key, and make this work:
Pause SABnzbd:
Resume SABnzbd:
Does that work? Check on the commandline and in SABnzbd.
If so, proceed:
Fill out your own API-key, and make this work:
Pause SABnzbd:
Code: Select all
$ curl 'http://127.0.0.1:8080/api?mode=pause&apikey=b463b755ad289e4fd2e2e7319ab6eaca'
ok
Code: Select all
$ curl 'http://127.0.0.1:8080/api?mode=resume&apikey=b463b755ad289e4fd2e2e7319ab6eaca'
ok
Re: pause download if not connected to acertain public ip-ad
No, it says -sh: $: command not found. Without the $ a lot of garbage runs over the screen ..
BTW ... I assume you mean by "check in sabnzbd" to check if it really paused or restarted..
Well, in second instance.... Without the $ upfront and filling out the port where sabnzbd is listining on in my computer (8800 instead of 8080)... it works ;-)
BTW ... I assume you mean by "check in sabnzbd" to check if it really paused or restarted..
Well, in second instance.... Without the $ upfront and filling out the port where sabnzbd is listining on in my computer (8800 instead of 8080)... it works ;-)
Re: pause download if not connected to acertain public ip-ad
OK, good.
Now create a shell script "sab-check-public-ip.sh" in your home directory that combines the above, so something like:
Make the script executable:
and run it. Does it work in both situations (VPN and no VPN)?
You can check your sabnzbd.log:
Now create a shell script "sab-check-public-ip.sh" in your home directory that combines the above, so something like:
Code: Select all
#!/bin/sh
curl -s -4 http://self-test.sabnzbd.org/ | grep -e "^45.71" > /dev/null && curl 'http://127.0.0.1:8080/api?mode=resume&apikey=b463b755ad289e4fd2e2e7319ab6eaca'|| curl 'http://127.0.0.1:8080/api?mode=pause&apikey=b463b755ad289e4fd2e2e7319ab6eaca'
Code: Select all
chmod +x sab-check-public-ip.sh
You can check your sabnzbd.log:
Code: Select all
$ cat ~/.sabnzbd/logs/sabnzbd.log | grep -i api | tail -2
2016-05-25 09:10:42,335::DEBUG::[interface:458] API-call from ::ffff:127.0.0.1 [curl/7.35.0] {'apikey': u'b463b755ad289e4fd2e2e7319ab6eaca', 'mode': u'pause'}
2016-05-25 09:11:23,157::DEBUG::[interface:458] API-call from ::ffff:127.0.0.1 [curl/7.35.0] {'apikey': u'b463b755ad289e4fd2e2e7319ab6eaca', 'mode': u'resume'}
Re: pause download if not connected to acertain public ip-ad
Looks like magic to me!!! It works. And thanks for so many help!!
Somethings i don't understand however, can you explain to me?:
1. What's the function of the first pipe "|" in the syntax?
2. Why is this character "^" used in front of the ip
3. Am i correct in assuming that "> dev/null" sends the result of the grep match into the interpreter (i.e. true or false)
4. What is the function of "&&" in the syntax
5 i assume the double pipe "||" divides the commands to execute whether the grep test was positive or negative?
Somethings i don't understand however, can you explain to me?:
1. What's the function of the first pipe "|" in the syntax?
2. Why is this character "^" used in front of the ip
3. Am i correct in assuming that "> dev/null" sends the result of the grep match into the interpreter (i.e. true or false)
4. What is the function of "&&" in the syntax
5 i assume the double pipe "||" divides the commands to execute whether the grep test was positive or negative?
Re: pause download if not connected to acertain public ip-ad
funny the cat command doens't work from any directory using ~. The cat command works however from the logs directory
Re: pause download if not connected to acertain public ip-ad
Looks like magic to me!!! It works. And thanks for so many help!!
Good. But wait, there is more: put it in cron / crontab that it is run each 5 minutes:
then
and add a line like this:
A lot of Unix/Linux concepts put into one command line ...
Good. But wait, there is more: put it in cron / crontab that it is run each 5 minutes:
Code: Select all
crontab -l
Code: Select all
crontab -e
Code: Select all
*/5 * * * * /home/<yourusername>/sab-check-public-ip.sh
Pipe the output from the first command into the second commandSomethings i don't understand however, can you explain to me?:
1. What's the function of the first pipe "|" in the syntax?
Regexp for "at the beginning of the line"2. Why is this character "^" used in front of the ip
No, it sends the text output into a null device (so: a black hole)3. Am i correct in assuming that "> dev/null" sends the result of the grep match into the interpreter (i.e. true or false)
Logical AND. So that command will only execute if the earlier command gave a return code other than 0. It's a trick.4. What is the function of "&&" in the syntax
Logical OR. That command is executed if the return code was 0. It's a trick.5 i assume the double pipe "||" divides the commands to execute whether the grep test was positive or negative?
A lot of Unix/Linux concepts put into one command line ...
Re: pause download if not connected to acertain public ip-ad
finally beat the crontab... it is working ;-) Super
Is it also possible to add sending a notification? (par example through pushbullet via sabnzbd using an api call)
There is an option in sabnzbd that notifies when nzb added/paused/resumed, but i only want to be informed about pause or resume...
Is it also possible to add sending a notification? (par example through pushbullet via sabnzbd using an api call)
There is an option in sabnzbd that notifies when nzb added/paused/resumed, but i only want to be informed about pause or resume...
Re: pause download if not connected to acertain public ip-ad
Google "pushbullet linux command line" ... that gives hopeful results.
As soon as you have that working on the command line, you can add it the script. That will take same extra lines of codes, as you have to check the current status, as you only want to send a line if you change the state.
As soon as you have that working on the command line, you can add it the script. That will take same extra lines of codes, as you have to check the current status, as you only want to send a line if you change the state.
Re: pause download if not connected to acertain public ip-ad
Ran into ssl certificate problems and so on... Running on a qnap nas and not familiar enough with all the packages and solutions. It seems entware-ng has a solution, but i had my share for today. Afraid to disturb the running configuration. Would be nice if the notification in sabnzbd could be splitted so that nzb added, paused and resumed could be set as individual notification settings.
Thanks for all your help!
Thanks for all your help!