-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from arniebarni/master
pull uap & serial from arniebarni
- Loading branch information
Showing
7 changed files
with
73 additions
and
24 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# Create the virtual device | ||
/sbin/iw dev wlan0 interface add uap0 type __ap | ||
ifup uap0 | ||
# Fetch wifi channel | ||
CHANNEL=`iwlist wlan0 channel | grep Current | sed 's/.*Channel \([0-9]*\).*/\1/g'` | ||
export CHANNEL | ||
# Create the config for hostapd | ||
cat /etc/hostapd/hostapd.conf.tmpl | envsubst > /etc/hostapd/hostapd.conf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,15 @@ else | |
echo 'dtparam=i2c_arm=on' >> /boot/config.txt | ||
fi | ||
|
||
# enable serial login on Raspberry Pi zero | ||
if grep -q 'Zero' /proc/device-tree/model; then | ||
echo 'Configuring Serial Login' | ||
echo ' dtoverlay=dwc2' >> /boot/config.txt | ||
echo ' modules-load=dwc2,g_serial' >> /boot/cmdline.txt | ||
echo '^wg_serial' >> /etc/modules | ||
systemctl enable [email protected] | ||
fi | ||
|
||
# Enable Wifi-Stick on Raspberry Pi 1 & 2 | ||
if grep -q '^net.ifnames=0' /boot/cmdline.txt; then | ||
echo '6 - Seems net.ifnames=0 parameter already set, skip this step.' | ||
|
@@ -114,8 +123,14 @@ fi | |
|
||
# wifi networks | ||
echo '>>> Setup Wifi Configuration' | ||
cp overlays/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf | ||
if grep -q 'network={' /etc/wpa_supplicant/wpa_supplicant.conf; then | ||
echo 'Seems networks are configure, skip this step.' | ||
else | ||
cp overlays/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf | ||
echo 'Remember to configure your WiFi credentials in /etc/wpa_supplicant/wpa_supplicant.conf' | ||
fi | ||
cp overlays/interfaces /etc/network/interfaces | ||
cp overlays/dhcpcd.conf.tmpl /etc/dhcpcd.conf.tmpl | ||
|
||
|
||
# Autostart | ||
|
@@ -131,29 +146,28 @@ fi | |
# AccessPoint | ||
echo '>>> Set Up Raspberry Pi as Access Point' | ||
apt-get install -y dnsmasq hostapd | ||
systemctl disable dnsmasq | ||
systemctl disable hostapd || (systemctl unmask hostapd && systemctl disable hostapd) | ||
systemctl stop dnsmasq | ||
systemctl stop hostapd | ||
# Configuring a static IP | ||
cp overlays/dhcpcd.conf /etc/dhcpcd.conf | ||
service dhcpcd restart && systemctl daemon-reload | ||
|
||
#Start in client mode | ||
# Configuring the DHCP server (dnsmasq) | ||
mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig | ||
cp overlays/dnsmasq.conf /etc/dnsmasq.conf | ||
# Configuring the access point host software (hostapd) | ||
cp overlays/hostapd.conf /etc/hostapd/hostapd.conf | ||
cp overlays/hostapd /etc/default/hostapd | ||
# Start it up | ||
systemctl start hostapd | ||
systemctl start dnsmasq | ||
|
||
# Add routing and masquerade | ||
cp overlays/sysctl.conf /etc/sysctl.conf # sysctl -w net.ipv4.ip_forward=1 | ||
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | ||
sh -c "iptables-save > /etc/iptables.ipv4.nat" | ||
if grep -q 'iptables-restore < /etc/iptables.ipv4.nat' /etc/rc.local; then | ||
echo 'Seems "iptables-restore < /etc/iptables.ipv4.nat" already in rc.local, skip this step.' | ||
else | ||
sed -i -e '$i \iptables-restore < /etc/iptables.ipv4.nat\n' /etc/rc.local | ||
fi | ||
#cp overlays/sysctl.conf /etc/sysctl.conf # sysctl -w net.ipv4.ip_forward=1 | ||
#iptables -t nat -A POSTROUTING -j MASQUERADE | ||
#sh -c "iptables-save > /etc/iptables.ipv4.nat" | ||
#if grep -q 'iptables-restore < /etc/iptables.ipv4.nat' /etc/rc.local; then | ||
# echo 'Seems "iptables-restore < /etc/iptables.ipv4.nat" already in rc.local, skip this step.' | ||
#else | ||
# sed -i -e '$i \iptables-restore < /etc/iptables.ipv4.nat\n' /etc/rc.local | ||
#fi | ||
|
||
echo | ||
# Replace HoneyPi files with latest releases | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
#request subnet-mask, broadcast-address, time-offset, routers, | ||
# domain-name, domain-name-servers, domain-search | ||
|
||
option domain_name_servers | ||
|
||
interface uap0 inet static | ||
address 192.168.4.1 | ||
netmask 255.255.255.0 | ||
network 192.168.4.0 | ||
broadcast 192.168.4.255 | ||
gateway 192.168.4.1 | ||
|
||
interface wlan0 | ||
static ip_address=192.168.4.1/24 | ||
nohook wpa_supplicant |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
interface=wlan0 # Use the require wireless interface - usually wlan0 | ||
interface=lo,uap0 | ||
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h | ||
dhcp-option=3,192.168.4.1 # Default Gateway | ||
dhcp-option=3,192.168.4.1 # Default Gateway | ||
no-dhcp-interface=lo,wlan0 | ||
#bind-interfaces |
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
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
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