#!/bin/sh # this goes into /etc/initramfs-tools/scripts/init-premount/a_enable_wireless PREREQ="" prereqs() { echo "$PREREQ" } case $1 in prereqs) prereqs exit 0 ;; esac . /scripts/functions AUTH_LIMIT=30 INTERFACE="wlan0" alias WPACLI="/sbin/wpa_cli -p/tmp/wpa_supplicant -i$INTERFACE " log_begin_msg "Setting WLAN regdomain" # Set this to your region /sbin/iw reg set PL log_begin_msg "Starting WLAN connection" sleep 1 && /sbin/wpa_supplicant -i$INTERFACE -c/etc/wpa_supplicant.conf -P/run/initram-wpa_supplicant.pid -B -f /tmp/wpa_supplicant.log # Wait for AUTH_LIMIT seconds, then check the status limit=${AUTH_LIMIT} echo -n "Waiting for connection (max ${AUTH_LIMIT} seconds)" while [ $limit -ge 0 -a `WPACLI status | grep wpa_state` != "wpa_state=COMPLETED" ] do sleep 1 echo -n "." limit=`expr $limit - 1` done echo "" if [ `WPACLI status | grep wpa_state` != "wpa_state=COMPLETED" ]; then ONLINE=0 log_failure_msg "WLAN offline after timeout" panic else ONLINE=1 log_success_msg "WLAN online" fi configure_networking