Hello all, is there an easy way I can do this? I want NZBGet to connect to a VPN when it gets an NZB before downloading, then disconnect when the queue is empty. I'm on OS X.
Any thoughts?
Code: Select all
scutil --nc start NameOfVPN
scutil --nc stop NameOfVPN
scutil --nc status NameOfVPN
Code: Select all
#!/bin/bash
set -e
#set -x
vpn="MyVPNName"
check_connecttion () {
status=`scutil --nc status ${vpn} | sed -n 1p`
if [ $status = "Connected" ]; then
return
else
return 1
fi
}
start_connection() {
scutil --nc start "${vpn}"
}
close_connection() {
scutil --nc stop "${vpn}"
}
wait_for_status ()
{
counter=$2
while [ ${counter} -gt 0 ]; do
check_connecttion
[ $? -eq $1 ] && return
let counter=counter-1
sleep 1
done
return 1
}
if check_connecttion; then
echo "im connected, disconnecting now!"
wait_for_status 1 10 || close_connection
else
echo "not connected, connecting now!"
wait_for_status 0 10 || start_connection
fi
Users browsing this forum: No registered users and 62 guests