diff options
Diffstat (limited to 'zeno-wifi.sh')
-rwxr-xr-x | zeno-wifi.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/zeno-wifi.sh b/zeno-wifi.sh new file mode 100755 index 0000000..36fa3d4 --- /dev/null +++ b/zeno-wifi.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +source ~/zeno-wifi.config + +sudo ifconfig wlan0 up +sudo iw dev wlan0 scan | grep -Po "(?<=SSID: ).*" | sort -u >/tmp/visible.networks +sudo ifconfig wlan0 down + +KNOWN="$({ + cat /tmp/visible.networks + netctl list | cut -b3- +} | sort | uniq -d | head -1)" + + +if [[ -n "$KNOWN" ]]; then + echo "Connecting to $KNOWN" + sudo netctl start "$KNOWN" + netctl wait-online "$KNOWN" + + autossh -M $JUMP_PORT_BASE -f -N -T \ + -R "$((JUMP_PORT_BASE + 22)):localhost:22" \ + -R "$((JUMP_PORT_BASE + 80)):localhost:80" \ + -o "ServerAliveInterval 30" \ + -o "ServerAliveCountMax 2" \ + "$JUMP_HOST" + + ssh "$JUMP_HOST" bash "$JUMP_ONCONNECT" + +else + echo "No known networks available, starting AP" + sudo create_ap -n --no-virt -d -g 10.0.0.1 wlan0 "$WIFI_SSID" "$WIFI_PASS" +fi |