Skip to content

Instantly share code, notes, and snippets.

@tdack
Created July 3, 2014 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdack/8e3bf3fb9c5df6bc85cd to your computer and use it in GitHub Desktop.
Save tdack/8e3bf3fb9c5df6bc85cd to your computer and use it in GitHub Desktop.
/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