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

15
run.sh
View File

@@ -1,32 +1,37 @@
#!/bin/env bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
VPN=vpn0
# example run:
# sudonixe ./run.sh 908029
if [[ -z "$PEM_PASS" && -f "$DIR/.env" ]]; then
if [[ -z "$VPN_PEM_PASS" && -f "$DIR/.env" ]]; then
export $( grep "=" $DIR/.env | grep -v "#" | xargs )
fi
: ${PEM_PASS:?Missing but needed}
: ${VPN_PEM_PASS:?Missing but needed}
: ${VPN_USER:?Missing but needed}
: ${VPN_USER_PASS:?Missing but needed}
: ${1:?Missing topt but needed}
expect $DIR/run.exp $PEM_PASS $VPN_USER $VPN_USER_PASS $1
expect $DIR/run.exp $VPN_PEM_PASS $VPN_USER $VPN_USER_PASS $1
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
VPN=vpn0
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)"
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
# sudo nmcli connection modify Nokia ipv4.dns-search $NEW