-
-
Save aceisace/b53e93924c969ac47e2333e970c132b0 to your computer and use it in GitHub Desktop.
Raspberry Pi 3 access-point-setup
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 | |
# | |
# This version uses Debian Stretch, please use that version. | |
# Usage: curl -sSL https://gist.githubusercontent.com/aceisace/b53e93924c969ac47e2333e970c132b0/raw/b4fbeed6cbe74d306c1951dc03435b38132b034e/Raspberry-AP-Setup.sh | bash | |
echo -p "Please enter a SSID for your AP, followed by [ENTER]:" | |
read APSSID | |
echo "Your AP will be named $APSSID" | |
echo -p "Please enter a password for your AP, followed by [ENTER]:" | |
read APPASS | |
echo "Your AP password has been saved" | |
echo -e "\e[1;36m"Getting the system ready..."\e[0m" | |
echo -e "\e[1;36m"This may take a while..."\e[0m" | |
sudo apt-get remove --purge hostapd -yqq | |
sudo apt-get update -yqq | |
#sudo apt-get dist-upgrade -yqq | |
sudo apt-get install hostapd dnsmasq -yqq | |
echo -e "\e[1;36m"All right, the system is up to date"\e[0m" | |
echo -e "\e[1;36m"Editing dnsmasq.conf file..."\e[0m" | |
sudo cat > /etc/dnsmasq.conf <<EOF | |
interface=wlan0 | |
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h | |
EOF | |
echo -e "\e[1;36m"Editing the hostapd.conf file..."\e[0m" | |
sudo cat > /etc/hostapd/hostapd.conf <<EOF | |
interface=wlan0 | |
ssid=$APSSID | |
hw_mode=g | |
channel=6 | |
wmm_enabled=1 | |
macaddr_acl=0 | |
auth_algs=1 | |
ignore_broadcast_ssid=0 | |
wpa=2 | |
wpa_passphrase=$APPASS | |
wpa_key_mgmt=WPA-PSK | |
wpa_pairwise=CCMP | |
rsn_pairwise=CCMP | |
ieee80211n=1 | |
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] | |
EOF | |
echo -e "\e[1;36m"Modifying the interfaces file"\e[0m" | |
sudo sed -i -- 's/allow-hotplug wlan0//g' /etc/network/interfaces | |
sudo sed -i -- 's/iface wlan0 inet manual//g' /etc/network/interfaces | |
echo -e "\e[1;36m"Editing wpa_supplicant.conf and hostapd..."\e[0m" | |
sudo sed -i -- 's/ wpa-conf \/etc\/wpa_supplicant\/wpa_supplicant.conf//g' /etc/network/interfaces | |
sudo sed -i -- 's/#DAEMON_CONF=""/DAEMON_CONF="\/etc\/hostapd\/hostapd.conf"/g' /etc/default/hostapd | |
echo -e "\e[1;36m"Adding a few IP addresses in the interfaces file..."\e[0m" | |
sudo cat >> /etc/network/interfaces <<EOF | |
# Added by Access Point Setup | |
allow-hotplug wlan0 | |
iface wlan0 inet static | |
address 192.168.4.1 | |
netmask 255.255.255.0 | |
network 192.168.4.0 | |
EOF | |
sudo echo "denyinterfaces wlan0" >> /etc/dhcpcd.conf | |
echo -e "\e[1;36m"Starting and enabling hostapd and dnsmasq"\e[0m" | |
sudo systemctl enable hostapd | |
sudo systemctl enable dnsmasq | |
sudo service hostapd start | |
sudo service dnsmasq start | |
echo "All done! Please reboot to apply changes" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment