#!/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