diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2018-10-16 20:50:26 -0400 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2018-10-16 20:50:26 -0400 |
| commit | e25574100a1afe934dcda3f133c77cbd78a38388 (patch) | |
| tree | 08c3ec623dac51786bbf57da9f15dd2f19cdb2cb /wpaconfig | |
| parent | 17dca4c0f71ba761fd711ef52d033af434d05778 (diff) | |
| download | dotfiles-e25574100a1afe934dcda3f133c77cbd78a38388.tar.gz dotfiles-e25574100a1afe934dcda3f133c77cbd78a38388.tar.xz | |
Added a 'wpaconfig' command that sort of emulates the OpenBSD ifconfig for wireless devices but for Linux using wpasupplicant and busybox udhcpc
Diffstat (limited to 'wpaconfig')
| -rw-r--r-- | wpaconfig | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/wpaconfig b/wpaconfig new file mode 100644 index 0000000..418f246 --- /dev/null +++ b/wpaconfig @@ -0,0 +1,52 @@ +#!/bin/sh + +# wpa_supplicant -i wlp4s0 -c wpa/banagoat.conf + +__usage() { +cat <<EOF +$0 <interface> nwid "<ssid>" wpakey "<wpa_passwd>" +OR +$0 <interface> list +EOF +exit 1; +} + +_cfg='network={ + ssid="%s" + scan_ssid=1 + key_mgmt=WPA-PSK + psk="%s" +}' + +_nwid="" +_wpakey="" + +# Can and probably will be overridden +# _if="$(ip link | awk '/^[0-9]+.*wl/{print $2}' | sed -e's/:$//' | tr -d '\n')" +[ -z "$1" ] && __usage +_if="$1" ; shift + +if [ "$1" = "list" ] ; then + iw "$_if" scan | awk '/SSID:/{$1="";print $0}' | sed -ne's/^ //p' + exit 0; +fi + +_temp="$(mktemp)" + +while [ $# -gt 0 ] ; do case $1 in + nwid) _nwid="$2"; shift; shift ;; + wpakey) _wpakey="$2"; shift; shift ;; + *) __usage ;; +esac ; done + +[ -z "$_nwid" ] && __usage +[ -z "$_wpakey" ] && __usage + +# Write the config +printf "$_cfg" "$_nwid" "$_wpakey" > "$_temp" + + +tmux new-session -s wpa wpa_supplicant -i "$_if" -c "$_temp" \;\ + new-window busybox udhcpc -i "$_if" -f + + |
