Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 27 lines (23 sloc) 658 Bytes
KERNEL_MODULE=iwlagn
WIRELESS_IF=wlan0
WPA_CONF=/etc/wpa_supplicant/wpa_supplicant.conf
if [ $(whoami) != root ]; then
echo You must run this script as root 1>&2
exit 2
elif [ $(sudo -v &> /dev/null) ]; then #sudo exist
sudo "$0""$@"
exit 0
fi
if [ -z $(pgrep wpa_supplicant) ]; then
if [[ -n $(lsmod | grep ${KERNEL_MODULE} -m1) ]]; then
echo "loading module" ${KERNEL_MODULE}
modprobe ${KERNEL_MODULE} #load the module is needed
fi
ifconfig ${WIRELESS_IF} up
wpa_supplicant -Dwext -i${WIRELESS_IF} -c${WPA_CONF} &
else
wpa_cli reassociate
fi
if [[ ! -e /var/run/dhcpcd-${WIRELESS_IF}.pid ]]; then
dhcpcd ${WIRELESS_IF} -A -t 0 -b
fi