summaryrefslogtreecommitdiff
path: root/scriptlets/old_veepeen_toggler.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scriptlets/old_veepeen_toggler.sh')
-rwxr-xr-xscriptlets/old_veepeen_toggler.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/scriptlets/old_veepeen_toggler.sh b/scriptlets/old_veepeen_toggler.sh
new file mode 100755
index 0000000..ad48082
--- /dev/null
+++ b/scriptlets/old_veepeen_toggler.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+passentry="shigoto/vpn"
+CONN_NAME="cscotun0"
+
+if [ -n "$(ip address show | grep -iE "^[0-9]+: $CONN_NAME")" ]; then
+ echo "ALREADY CONNECTED. DISCONNECTING..."
+ /opt/cisco/anyconnect/bin/vpn disconnect
+else
+ CONN_HOST="$( pass $passentry | grep "url: "| sed -r "s|url: ||g" )"
+ CONN_CREDS_USERNAME="$( pass $passentry | grep "username: "| sed -r "s|username: ||g" )"
+ CONN_CREDS_PASSWORD="$( pass $passentry | head -n1 )"
+ echo "CONNECTING... DON'T FORGET YOUR PHONE VERIFICATION"
+ printf '%s\n%s' "$CONN_CREDS_USERNAME" "$CONN_CREDS_PASSWORD" | /opt/cisco/anyconnect/bin/vpn -s connect "$CONN_HOST"
+fi
+
+: '
+Note the single quotes instead of double quotes - this is because double quotes tell Bash to interpret certain characters within strings, such as exclamation marks, as Bash history commands. Double quotes will make this command fail with an "event not found" error if the password contains an exclamation mark. Single-quoted strings pass exclamation marks along without interpreting them.
+
+In case your client does not connect due to certificate validation error Certificate is from an untrusted source,
+and you still want to connect then pass a y parameter in the above method so that the command to connect becomes:
+printf "y\nUSERNAME\nPASSWORD\ny" | /opt/cisco/anyconnect/bin/vpn -s connect HOST.
+Note that do this only in the case that you absolutely trust your connection;
+otherwise there might be a middleman sitting in and snooping onto you.
+'