Skip to content

Instantly share code, notes, and snippets.

@aycabta
Last active October 6, 2015 12:10
Show Gist options
  • Save aycabta/20f41c73bba40c37f20a to your computer and use it in GitHub Desktop.
Save aycabta/20f41c73bba40c37f20a to your computer and use it in GitHub Desktop.
#!/usr/local/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: # ./setup_wifi.sh wifi_name"
echo "The \`wifi_name' is used for filename: /var/wpa_supplicant_[wifi_name].conf"
exit 1
fi
if [ $UID -ne 0 ]; then
echo "You must be a root."
exit 2
fi
CONF_PATH="/var/wpa_supplicant_$1.conf"
if [ ! -f ${CONF_PATH} ]; then
echo "${CONF_PATH} is not found."
exit 3
fi
if [ ! -r ${CONF_PATH} ]; then
echo "${CONF_PATH} can not be read."
exit 4
fi
ifconfig wlan0 destroy
ifconfig wlan create wlandev run0 up
wpa_supplicant -B -i wlan0 -c ${CONF_PATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment