Created
April 22, 2018 13:58
-
-
Save nicholasadamou/9b508c63dbb37df83ac2fde690c0a309 to your computer and use it in GitHub Desktop.
Configure the WiFi interface on Raspberry Pi 2/3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$(id -u)" != "0" ]; then | |
exec sudo "$0" "$@" | |
fi | |
ssid="" # Enter SSID of WiFi | |
passwd="" # Enter Password of Given WiFi SSID | |
interface="wlan0" | |
wpa_conf="/etc/wpa_supplicant/wpa_supplicant.conf" | |
systemctl stop network-manager && systemctl disable network-manager | |
ifconfig "$interface" up | |
wpa_passphrase "$ssid" "$passwd" > "$wpa_conf" | |
x="/etc/network/interfaces" | |
if ! [ -f "$x".bak ]; then | |
cp "$x" "$x".bak | |
fi | |
cat > "$x" <<EOF | |
auto lo | |
iface lo inet loopback | |
auto eth0 | |
iface eth0 inet dhcp | |
allow-hotplug "$interface" | |
iface "$interface" inet dhcp | |
wpa-conf "$wpa_conf" | |
EOF | |
wpa_supplicant -D wext -i "$interface" -c "$wpa_conf" & | |
dhclient -v "$interface" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment