nsbin/vpn.sh
Nico Schottelius 0b7ba88068
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 12s
updated by /home/nico/bin/sync-all-repos on nb3
2024-08-07 21:39:56 +02:00

111 lines
3.2 KiB
Bash
Executable file

#!/bin/sh
# 2022-02-10, 10:25, Nico Schottelius
set -e
set -x
case "$1" in
uzh|uzhsplit)
vpnc --no-detach "$1"
;;
uzhvnc)
pkill -f 5999:localhost:5900 || true
ssh -L5999:localhost:5900 -f -N uzh-macmini-ipv4
pass git co master
pass uzh/macmini/vnc-password -c
vncviewer localhost:99
;;
runa)
pass git checkout nico-privat
pass tws/runa/vpn-endpoint > /dev/null
endpoint=$(pass tws/runa/vpn-endpoint)
authgroup=$(pass tws/runa/vpn-authgroup)
vpn_user=$(pass tws/runa/vpn-user)
echo "Use: pass -c tws/runa/vpn-password"
authgroup=UK
authgroup=Malta
sudo openconnect \
--protocol=gp ${endpoint} \
--user ${vpn_user} \
--authgroup=${authgroup} \
--allow-insecure-crypto
;;
tws)
# Ensure we are on the right branch and pass has been unlocked
pass git checkout nico-privat
pass tws/nschottelius1 > /dev/null
if [ "$2" ]; then
authgroup="$2"
else
authgroup=Europe
fi
# Try to input the password directly, revert to non input if it fails
pass tws/nschottelius1 | sudo openconnect --protocol=gp portal.techcorpapps.com \
--allow-insecure-crypto --user nschottelius1 \
--passwd-on-stdin --authgroup=$authgroup || \
sudo openconnect --protocol=gp portal.techcorpapps.com \
--allow-insecure-crypto --user nschottelius1 \
--passwd-on-stdin --authgroup=$authgroup
;;
lx)
cd ~/Nextcloud/luxembourg/nico/
sudo openvpn --config nico.ovpn
;;
server*)
f=/etc/openvpn/${1}.conf
if [ -f "$f" ]; then
sudo modprobe tun
sudo openvpn --config ${f}
else
echo "Config file $f is missing"
exit 1
fi
;;
rmovpn)
sudo openvpn --config ~nico/Nextcloud/rulematch/nico-schottelius.ovpn
;;
rm)
case $(hostname) in
bridge)
sudo wg-quick up rmr1n2
sudo wg-quick up rmr3n2
sudo wg-quick up rmr5n2
;;
nb3)
sudo wg-quick up rmr1n1
sudo wg-quick up rmr3n1
sudo wg-quick up rmr5n1
;;
blind)
sudo wg-quick up rmr2n1
sudo wg-quick up rmr4n1
sudo wg-quick up rmr6n1
;;
mirror2)
sudo wg-quick up rmr2n2
sudo wg-quick up rmr4n2
sudo wg-quick up rmr6n2
;;
sun)
sudo wg-quick up rmr1n3
sudo wg-quick up rmr3n3
sudo wg-quick up rmr5n3
;;
sun2)
sudo wg-quick up rmr2n3
sudo wg-quick up rmr4n3
sudo wg-quick up rmr6n3
;;
*)
echo "Host does not have VPN assigned" >&2
exit 1
;;
esac
;;
*)
echo "$0 lf lx rm"
;;
esac