From cdf3d1d5acdce2b9baa8eeac8422b48fce899b50 Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Thu, 29 Dec 2022 18:40:18 -0500 Subject: Add a script for wpa_supplicant on linux --- bin/Makefile | 1 + bin/wpa | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100755 bin/wpa diff --git a/bin/Makefile b/bin/Makefile index 01a6333..0de88b5 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -3,6 +3,7 @@ default: install linux: install backlight $(HOME)/bin + install wpa $(HOME)/bin install: install -d $(HOME)/bin diff --git a/bin/wpa b/bin/wpa new file mode 100755 index 0000000..ea79adb --- /dev/null +++ b/bin/wpa @@ -0,0 +1,59 @@ +#!/bin/sh +set -e +session="wpa" +t=3 +interface= +nwid= +wpakey= + +help() { +cat <] [-n ] [-p ] +EOF +exit 1; +} + +while [ $# -gt 0 ] ; do case $1 in + -i|if) interface="$2"; shift ; shift ;; + -n|nwid) nwid="$2"; shift ; shift ;; + -p|wpakey) wpakey="$2"; shift ; shift ;; + *) help ;; +esac ; done + +err=0 +for _v in interface nwid wpakey ; do + eval v="\$$_v"; + if [ -z "$v" ] ; then + echo "$_v cannot be empty" + err=1 + fi +done +if [ $err -eq 1 ] ; then exit 1 ; fi + + +wpakey="$(echo "$wpakey" | sed -e's/"/\\"/g')" + +conf_f="$(mktemp /dev/shm/wpa.XXXX)" +trap 'rm -f $conf_f; exit 1;' EXIT INT +cat > "$conf_f" <