-
-
Save atlury/fe0ea8b91a981c103df7 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
Dear Atlury,
I have just loaded noobs and have created a media server. Now I want to use the PI3 wifi as Access point. The code looks very useful. Now please tell me,
I am novice in PI coding etc. If I am asking some silly question, please forgive me.