freebsd helper scripts
authorAndreas Bilke <andreas@bilke.org>
Tue, 12 Jun 2018 17:29:43 +0000 (19:29 +0200)
committerAndreas Bilke <andreas@bilke.org>
Tue, 12 Jun 2018 17:30:08 +0000 (19:30 +0200)
freebsd/wifi-connect [new file with mode: 0755]

diff --git a/freebsd/wifi-connect b/freebsd/wifi-connect
new file mode 100755 (executable)
index 0000000..ec49ffb
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -e
+set -u
+set -f
+
+if [ $# -ne 1 ]; then
+    echo "usage: wifi-connect <SSID>" >&2
+    exit 1
+fi
+SSID="$1"
+WPA_SUPPLICANT_CONFIG_FILE="/usr/local/etc/wpa_supplicant/$SSID.conf"
+if [ ! -e $WPA_SUPPLICANT_CONFIG_FILE ]; then
+    echo "can't find config file for $SSID" >&2
+    exit 1
+fi
+
+ifconfig wlan0 create wlandev iwm0
+wpa_supplicant -i wlan0 -c "$WPA_SUPPLICANT_CONFIG_FILE" &
+dhclient wlan0