Added basic checks and the ability to stop the VPN
This commit is contained in:
parent
c53b242508
commit
069cbe1732
@ -0,0 +1,3 @@
|
|||||||
|
Very basic openvpn-client management script.
|
||||||
|
|
||||||
|
Note this is bad and I do feel bad.
|
||||||
28
vpnnew.sh
28
vpnnew.sh
@ -1,15 +1,35 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo "This script must be run as root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
tmpfile="/tmp/connectedto"
|
tmpfile="/tmp/connectedto"
|
||||||
vpnconfpath="/etc/openvpn/client"
|
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 () {
|
function weAreConnected () {
|
||||||
if [ -f $tmpfile ]
|
if [ -f $tmpfile ]
|
||||||
then
|
then
|
||||||
echo "We are connected to `cat $tmpfile`"
|
echo "We are connected to `cat $tmpfile`"
|
||||||
if [[ $1 == "stop" ]]
|
# if [[ $1 == "stop" ]]
|
||||||
then
|
# then
|
||||||
|
# systemctl stop openvpn-client@`cat $tmpfile`
|
||||||
|
# fi
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
"stop")
|
||||||
|
echo "Stopping VPN Connection"
|
||||||
systemctl stop openvpn-client@`cat $tmpfile`
|
systemctl stop openvpn-client@`cat $tmpfile`
|
||||||
fi
|
;;
|
||||||
|
*)
|
||||||
|
helpertext
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -17,7 +37,7 @@ fi
|
|||||||
## Check for tunnel device to see if we are connected
|
## Check for tunnel device to see if we are connected
|
||||||
if [ -d /sys/class/net/tun0 ]
|
if [ -d /sys/class/net/tun0 ]
|
||||||
then
|
then
|
||||||
weAreConnected
|
weAreConnected $1
|
||||||
else
|
else
|
||||||
connected=0
|
connected=0
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user