Skip to content

Instantly share code, notes, and snippets.

@tdack
Created Jul 3, 2014
Embed
What would you like to do?
/etc/initramfs-tools/scripts/local-top/wlan
#!/bin/sh
# Boot script to bring up wlan interface using wpa_supplicant before rest of boot process
PREREQ="udev"
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
# Begin real processing below this line
if [ ! -x "/sbin/wpa_supplicant" ]; then
panic "wpa_supplicant executable not found"
fi
. /conf/initramfs.conf
for conf in conf/conf.d/*; do
[ -f ${conf} ] && . ${conf}
done
. /scripts/functions
log_begin_msg "Starting wpa_supplicant for ${DEVICE}"
/sbin/wpa_supplicant -B -Dwext -i${DEVICE} -C /run/wpa_supplicant/ -c /etc/wpa_supplicant/wpa_supplicant.conf
sleep 5
if [ ! -e "/run/wpa_supplicant/${DEVICE}" ]; then
log_failure_msg "wpa_supplicant failed for ${DEVICE}"
panic "wpa_supplicant failed for ${DEVICE}"
fi
log_end_msg
log_begin_msg "Starting IP configuration for ${DEVICE}"
for ROUNDTTT in 2 3 4 6 9 16 25 36 64 100; do
# The NIC is to be configured if this file does not exist.
# Ip-Config tries to create this file and when it succeeds
# creating the file, ipconfig is not run again.
for x in /run/net-"${DEVICE}".conf ; do
[ -e "$x" ] && break 2
done
ipconfig -t ${ROUNDTTT} "${DEVICE}"
done
# source ipconfig output
if [ -n "${DEVICE}" ]; then
# source specific bootdevice
. /run/net-${DEVICE}.conf
else
# source any interface...
# ipconfig should have quit after first response
. /run/net-*.conf
fi
log_end_msg
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment