added nix

This commit is contained in:
Zsolt Alföldi
2025-10-26 02:30:16 +02:00
parent 85e4396dd1
commit 2aed3ade72
9 changed files with 131 additions and 9 deletions

27
nix.sh Normal file
View File

@@ -0,0 +1,27 @@
#!/bin/env bash
set -e -u -o pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
VPN=vpn0
dot_env_secret=$(echo 'U2FsdGVkX1+ZpYMKJgqLZC7uedR4GhfB6/8Q+xdq0rH9v2S/pNTBBpdjlS/Fy5eNRsMGRSYf/HoZNihIYiAskKOY7mg6+t5vRUXWh73BQHuUVD2uAUc5npgP/Lmyn2wR2qWoBfTToKeu0nI5Gh7VQw==' | \
openssl enc -aes-256-cbc -pbkdf2 -d -a -A -pass pass:$1)
export $( echo $dot_env_secret | grep "=" | grep -v "#" | xargs )
expect $DIR/vpn.exp $VPN_PEM_PASS $VPN_USER $VPN_USER_PASS $2
sudo ip route delete 10.0.0.0/8 dev $VPN metric 50 || true
sudo ip route delete 100.0.0.0/8 dev $VPN metric 50 || true
sudo ip route delete 135.0.0.0/8 dev $VPN metric 50 || true
EXISTING=$(nmcli -g ipv4.dns-search connection show "$VPN")
NEW="${EXISTING:+$EXISTING,}cci.nokia.net"
vpn_ip="$(ip a l $VPN | awk '/inet / {print $2}' | cut -d/ -f1 | cut -d. -f1-3)"
if [[ -z $vpn_ip ]] ; then
exit 1
fi
sudo ip route add 10.0.0.0/8 dev $VPN metric 50
sudo ip route add 100.0.0.0/8 dev $VPN metric 50
sudo ip route add 135.0.0.0/8 dev $VPN metric 50