-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·39 lines (30 loc) · 1.14 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# Set up a Raspberry Pi 2B as wifi access point (AP).
# The AP will obtain an IP address via DHCP through eth0.
# DHCP requests of clients are passed to the DHCP server in the network.
# exit if anything goes wrong
set -e
# install needed packages
sudo apt update
sudo apt -y install hostapd bridge-utils
# disable dhcp client and wpa_supplicant for the wireless interface
# disable dhcp for eth0, use bridge instead
sudo printf '\ndenyinterfaces wlan0 br0\n' | sudo tee -a /etc/dhcpcd.conf
# use AP configuration at this path
sudo printf '\nDAEMON_CONF="/etc/hostapd/hostapd.conf"\n' | sudo tee -a /etc/default/hostapd
# copy the actual configuration to destination
sudo cp hostapd.conf /etc/hostapd/hostapd.conf
# create bridge
sudo brctl addbr br0
# add add ethernet interface to bridge
sudo brctl addif br0 eth0
# configure network interfaces
sudo cp ifcfg-wifi_ap /etc/network/interfaces.d/
# start hostapd service
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
# start wifi interface
sudo ifconfig wlan0 up
echo 'Finished setting up!'
# reboot to apply configuration and start hostapd service
echo 'Please reboot now.'