44 lines
773 B
Bash
Executable File
44 lines
773 B
Bash
Executable File
#!/bin/bash
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo "This script must be run as root"
|
|
exit 1
|
|
fi
|
|
|
|
tmpfile="/tmp/connectedto"
|
|
vpnconfpath="/etc/openvpn/client"
|
|
|
|
function helpertext () {
|
|
echo "VPN Manager Help Text"
|
|
echo "When connected yo have the following options"
|
|
echo "stop - This stopps the VPN connection"
|
|
}
|
|
|
|
function weAreConnected () {
|
|
if [ -f $tmpfile ]
|
|
then
|
|
echo "We are connected to `cat $tmpfile`"
|
|
# if [[ $1 == "stop" ]]
|
|
# then
|
|
# systemctl stop openvpn-client@`cat $tmpfile`
|
|
# fi
|
|
|
|
case $1 in
|
|
"stop")
|
|
echo "Stopping VPN Connection"
|
|
systemctl stop openvpn-client@`cat $tmpfile`
|
|
;;
|
|
*)
|
|
helpertext
|
|
esac
|
|
fi
|
|
|
|
}
|
|
|
|
## Check for tunnel device to see if we are connected
|
|
if [ -d /sys/class/net/tun0 ]
|
|
then
|
|
weAreConnected $1
|
|
else
|
|
connected=0
|
|
fi
|