84 lines
2.4 KiB
Bash
Executable file
84 lines
2.4 KiB
Bash
Executable file
#!/bin/sh
|
|
# 2022-02-10, 10:25, Nico Schottelius
|
|
|
|
set -e
|
|
|
|
case "$1" in
|
|
uzh|uzhsplit)
|
|
vpnc --no-detach "$1"
|
|
;;
|
|
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
|
|
;;
|
|
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
|