fixed Login failed, added DIR
This commit is contained in:
6
run.exp
6
run.exp
@@ -38,6 +38,12 @@ expect {
|
|||||||
send "$otp\r"
|
send "$otp\r"
|
||||||
exp_continue
|
exp_continue
|
||||||
}
|
}
|
||||||
|
-re "Login failed." {
|
||||||
|
send_user "Detected: Login failed. Exiting.\n"
|
||||||
|
close
|
||||||
|
wait
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
eof
|
eof
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
run.sh
14
run.sh
@@ -1,9 +1,20 @@
|
|||||||
#!/bin/env bash
|
#!/bin/env bash
|
||||||
|
set -e
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
|
||||||
|
|
||||||
# example run:
|
# example run:
|
||||||
# sudonixe ./run.sh 908029
|
# sudonixe ./run.sh 908029
|
||||||
|
|
||||||
expect run.exp $PEM_PASS $VPN_USER $VPN_USER_PASS $1
|
if [[ -z "$PEM_PASS" && -f "$DIR/.env" ]]; then
|
||||||
|
export $( grep "=" $DIR/.env | grep -v "#" | xargs )
|
||||||
|
fi
|
||||||
|
|
||||||
|
: ${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
|
||||||
|
|
||||||
VPN=vpn0
|
VPN=vpn0
|
||||||
EXISTING=$(nmcli -g ipv4.dns-search connection show "$VPN")
|
EXISTING=$(nmcli -g ipv4.dns-search connection show "$VPN")
|
||||||
@@ -11,7 +22,6 @@ 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
|
if [[ -z $vpn_ip ]] ; then
|
||||||
echo 'Vpn not foudn'
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user