-
-
Save kosso/e02f4cb471c6d67607f2 to your computer and use it in GitHub Desktop.
Raspberry Pi 3 access-point-setup
This file contains 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 pass a password!" | |
echo "Usage:" | |
echo "sudo $0 yourChosenPassword [apName]" | |
exit | |
fi | |
$APPASS=$1 | |
$APSSID="rPi3" | |
if [[ $# -eq 2 ]]; | |
$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=$APNAME | |
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 | |
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