-
-
Save juzam/098a3b8fea8b9201225d02a0558c0f31 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 | |
if [ "$EUID" -ne 0 ]; then | |
echo "Must be root" | |
exit | |
fi | |
if [[ $# -ne 1 ]]; then | |
echo "You need to set a password!" | |
echo "Usage:" | |
echo "sudo $0 yourChosenPassword [apName]" | |
exit | |
fi | |
APPASS=$1 | |
APSSID="rPi3" | |
if [[ $# -eq 2 ]]; then | |
APSSID=$2 | |
fi | |
apt-get remove --purge hostapd -y | |
apt-get install hostapd dnsmasq -y | |
cat > /etc/dnsmasq.conf <<EOF | |
interface=wlan0 | |
dhcp-range=10.0.0.2,10.0.0.5,255.255.255.0,12h | |
EOF | |
cat > /etc/hostapd/hostapd.conf <<EOF | |
interface=wlan0 | |
hw_mode=g | |
channel=10 | |
auth_algs=1 | |
wpa=2 | |
wpa_key_mgmt=WPA-PSK | |
wpa_pairwise=CCMP | |
rsn_pairwise=CCMP | |
wpa_passphrase=$APPASS | |
ssid=$APSSID | |
EOF | |
sed -i -- 's/exit 0/ /g' /etc/rc.local | |
cat >> /etc/rc.local <<EOF | |
ifconfig wlan0 down | |
ifconfig wlan0 10.0.0.1 netmask 255.255.255.0 up | |
iwconfig wlan0 power off | |
iwconfig wlan0 mode Master | |
service dnsmasq restart | |
hostapd -B /etc/hostapd/hostapd.conf & > /dev/null 2>&1 | |
exit 0 | |
EOF | |
echo "All done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment