commit eb8d8c4c422905a78831f3881024dd2fe342460c
parent 6298ab4f67388f241d0221d3f8a8d7ce553efc68
Author: pyratebeard <root@pyratebeard.net>
Date: Thu, 21 May 2020 20:59:07 +0100
update to vars and nameserver entry
dynamically get the wifi device name using iw command. use vars for vpn key file. utilise resolvconf command to enter new nameservers instead of copying file
Diffstat:
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/bin/bin/connect b/bin/bin/connect
@@ -1,10 +1,12 @@
#!/usr/bin/env zsh
# vars
-WIFI_DEV="wlp3s0"
+WIFI_DEV=$(iw dev | awk '$1=="Interface"{print $2}')
CONNECTION_FILE_PATH="$HOME/lib/doc/wifi/"
-CONNECTION_FILE=$CONNECTION_FILE_PATH$1
+CONNECTION_FILE="${CONNECTION_FILE_PATH}${1}"
CONNECTION=$(echo ${CONNECTION_FILE} | awk -F\/ '{print $NF}')
+VPN_KEY_PATH="$HOME/lib/key"
+VPN_KEY="${VPN_KEY_PATH}/$(hostname -s).ovpn"
if [ ! $1 ] ; then
echo "specify a connection file"
@@ -39,11 +41,12 @@ sudo dhcpcd -b -4 ${WIFI_DEV} >/dev/null 2>&1
function use_vpn() {
echo "not at home, starting vpn"
sleep 20
- sudo openvpn --config lib/key/wht-rht-obj.ovpn --daemon >/dev/null 2>&1
+ sudo openvpn --config ${VPN_KEY} --daemon >/dev/null 2>&1
sudo systemd-tty-ask-password-agent
echo "waiting for vpn..."
sleep 60
- sudo cp $HOME/tmp/opendns /etc/resolv.conf
+ echo "nameserver 208.67.222.222
+ nameserver 208.67.220.220" | sudo resolvconf -a ${WIFI_DEV}.inet
sudo ip route add 192.168.0.0/24 via 10.8.0.13 dev tun0
while :
ping -q -c1 fortkickass >/dev/null
@@ -57,7 +60,7 @@ function use_vpn() {
}
# when remote bring ip vpn
case "${CONNECTION}" in
- home) ;; #|artoo) ;;
+ home) ;; |work) ;;
*) use_vpn ;;
esac
diff --git a/bin/bin/disconnect b/bin/bin/disconnect
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-WIFI_DEV="wlp3s0"
+WIFI_DEV=$(iw dev | awk '$1=="Interface"{print $2}')
killit() {
if $(pidof ${1} >/dev/null) ; then