Skip to content

Commit

Permalink
Merge pull request #1 from arniebarni/master
Browse files Browse the repository at this point in the history
pull uap & serial from arniebarni
  • Loading branch information
elschnorro77 authored Jan 15, 2020
2 parents c6a7e93 + 4297307 commit 23b0b1a
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 24 deletions.
9 changes: 9 additions & 0 deletions create_uap
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
44 changes: 29 additions & 15 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 11 additions & 3 deletions overlays/dhcpcd.conf
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
6 changes: 4 additions & 2 deletions overlays/dnsmasq.conf
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
5 changes: 3 additions & 2 deletions overlays/hostapd.conf → overlays/hostapd.conf.tmpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
interface=wlan0
interface=uap0
driver=nl80211
ssid=HoneyPi
hw_mode=g
channel=7
channel=${CHANNEL}
wmm_enabled=0
macaddr_acl=0
auth_algs=1
Expand All @@ -12,3 +12,4 @@ wpa_passphrase=HoneyPi!
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_pairwise=TKIP CCMP
country_code=DE
14 changes: 14 additions & 0 deletions overlays/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,17 @@

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

iface wlan0 inet dhcp

auto uap0
5 changes: 3 additions & 2 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# install HoneyPi rpi-scripts
echo '>>> Install HoneyPi runtime measurement scripts'
ScriptsTag=$(curl --silent "https://api.github.com/repos/Honey-Pi/rpi-scripts/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
ScriptsTag=$(curl --silent "https://api.github.com/repos/arniebarni/rpi-scripts/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
if [ $ScriptsTag ]; then
rm -rf rpi-scripts # remove folder to download latest
echo ">>> Downloading rpi-scripts $ScriptsTag"
wget "https://codeload.github.com/Honey-Pi/rpi-scripts/zip/$ScriptsTag" -O HoneyPiScripts.zip
wget "https://codeload.github.com/arniebarni/rpi-scripts/zip/$ScriptsTag" -O HoneyPiScripts.zip
unzip HoneyPiScripts.zip
mv $DIR/rpi-scripts-${ScriptsTag//v} $DIR/rpi-scripts
sleep 1
Expand All @@ -43,6 +43,7 @@ if [ $WebinterfaceTag ]; then
echo ">>> Downloading rpi-webinterface $WebinterfaceTag"
wget "https://codeload.github.com/Honey-Pi/rpi-webinterface/zip/$WebinterfaceTag" -O HoneyPiWebinterface.zip
unzip HoneyPiWebinterface.zip
mkdir -p /var/www
mv $DIR/rpi-webinterface-${WebinterfaceTag//v}/dist /var/www/html
mv $DIR/rpi-webinterface-${WebinterfaceTag//v}/backend /var/www/html/backend
sleep 1
Expand Down

0 comments on commit 23b0b1a

Please sign in to comment.