24 lines
391 B
Bash
Executable File
24 lines
391 B
Bash
Executable File
#!/bin/bash
|
|
tmpfile="/tmp/connectedto"
|
|
vpnconfpath="/etc/openvpn/client"
|
|
|
|
function weAreConnected () {
|
|
if [ -f $tmpfile ]
|
|
then
|
|
echo "We are connected to `cat $tmpfile`"
|
|
if [[ $1 == "stop" ]]
|
|
then
|
|
systemctl stop openvpn-client@`cat $tmpfile`
|
|
fi
|
|
fi
|
|
|
|
}
|
|
|
|
## Check for tunnel device to see if we are connected
|
|
if [ -d /sys/class/net/tun0 ]
|
|
then
|
|
weAreConnected
|
|
else
|
|
connected=0
|
|
fi
|