initrd: Add wpa_supplicant
authorFrançois Tigeot <ftigeot@wolfpond.org>
Wed, 9 Apr 2014 15:56:50 +0000 (17:56 +0200)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Wed, 9 Apr 2014 21:20:42 +0000 (23:20 +0200)
Submitted-by: Matthew Dillon <dillon@apollo.backplane.com>
share/initrd/bin/Makefile
share/initrd/bin/dowpa [new file with mode: 0644]
share/initrd/etc/Makefile
share/initrd/etc/wpa_supplicant.conf [new file with mode: 0644]
share/initrd/sbin.libcrypto/Makefile

index 050f354..7e2f80a 100644 (file)
@@ -7,6 +7,7 @@ NO_MAN= YES
 
 PROG=  rescue
 BINDIR=        /usr/share/initrd/bin
+SCRIPTS=dowpa
 
 ###################################################################
 # Programs from stock /bin
diff --git a/share/initrd/bin/dowpa b/share/initrd/bin/dowpa
new file mode 100644 (file)
index 0000000..1404bea
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+if [ $# != 3 ]; then
+    echo "dowpa ath0 ssid password"
+    exit 1
+fi
+
+ifc=$1
+ssid=$2
+pass=$3
+
+killall -9 wpa_supplicant > /dev/null 2>&1
+sleep 0.5
+ifconfig wlan0 down > /dev/null 2>&1
+ifconfig wlan0 destroy > /dev/null 2>&1
+sleep 0.5
+
+cat > /etc/wpa_supplicant.conf << EOF
+network={
+    ssid="$ssid"
+    scan_ssid=1
+    psk="$3"
+}
+EOF
+
+ifconfig wlan0 create wlandev $ifc
+sleep 0.5
+/sbin/wpa_supplicant -B -q -i wlan0 -c /etc/wpa_supplicant.conf -D bsd \
+        -P /var/run/wpa_supplicant/wlan0.pid
+
index d5f80ac..55d4977 100644 (file)
@@ -1,4 +1,3 @@
-
 #If you want to add files to other subdirectories, please use a similar
 #approach as below, for example for var:
 #
@@ -6,12 +5,20 @@
 #add ${VAR_FILES} to FILES=
 #add a for loop for ${VAR_FILES}
 
-ETC_FILES=     rc rc.lvm2 rcmount_crypt rcmount_tcplay
-FILES=         ${ETC_FILES}
+ETC_SCRIPTS=   rc rc.lvm2 rcmount_crypt rcmount_tcplay
+FILES=         ${ETC_SCRIPTS}
 
-.for file in ${ETC_FILES}
+.for file in ${ETC_SCRIPTS}
 FILESDIR_${file}=${SHAREDIR}/initrd/etc
 FILESMODE_${file}=555
 .endfor
 
+# Files that should be installed read-only (444)
+#
+ETC_FILES=     ${.CURDIR}/wpa_supplicant.conf
+
+afterinstall:
+       ${INSTALL} -o root -g wheel -m 444 \
+               ${ETC_FILES} ${DESTDIR}${SHAREDIR}/initrd/etc
+
 .include <bsd.prog.mk>
diff --git a/share/initrd/etc/wpa_supplicant.conf b/share/initrd/etc/wpa_supplicant.conf
new file mode 100644 (file)
index 0000000..29cc5c6
--- /dev/null
@@ -0,0 +1,20 @@
+# Sample wpa_supplicant.conf
+#
+
+# wpa/wpa2
+#
+network={
+    ssid="ssidnamehere"
+    scan_ssid=1
+    psk="passwordhere"
+}
+
+# old wep
+#
+network={
+    ssid="ssidnamehere"
+    scan_ssid=1
+    key_mgmt=NONE
+    wep_tx_keyidx=0
+    wep_key0=HEXDIGITSFORKEY
+}
index 1efdd24..a4b86ef 100644 (file)
@@ -14,7 +14,11 @@ CRUNCH_PROGS_sbin= tcplay
 CRUNCH_SRCDIRS+= gnu/sbin
 CRUNCH_PROGS_gnu/sbin= cryptsetup
 
-CRUNCH_LIBS+= -lcrypto -ldm -lprop -lutil
+CRUNCH_LIBS+= -ldm -lprop -lutil
+
+CRUNCH_SRCDIRS+= usr.sbin/802_11
+CRUNCH_PROGS_usr.sbin/802_11= wpa_supplicant
+CRUNCH_LIBS+= -lpcap -lssl -lcrypto
 
 .include <bsd.crunchgen.mk>
 .include <bsd.prog.mk>