Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hostap update for Orange Pi #106

Merged
merged 13 commits into from
Oct 29, 2017
Merged
1 change: 1 addition & 0 deletions scripts/hostapd/dnsmasq.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
interface=wlan0
dhcp-range=10.0.0.2,10.0.0.127,255.255.255.0,12h
bind-interfaces
27 changes: 20 additions & 7 deletions scripts/hostapd/install
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ set -e
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Install hostapd and dnsmasq to run IEEE 802.11 Access Point
if ! [ "$(which hostapd)" ] || ! [ "$(which dnsmasq)" ]; then
sudo apt-get install hostapd dnsmasq radvd -y
fi
sudo apt-get install hostapd dnsmasq radvd dnsmasq iptables -y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Install packages to run IEEE 802.11 Access Point and dnsmasq is doubled


# Configure wlan0 interface
sudo cp /etc/network/interfaces /etc/network/interfaces.backup
Expand All @@ -16,6 +14,7 @@ if [ ! -z $START ]; then
END=$(expr $START + 3)
sudo sed -i "${START},${END}d" /etc/network/interfaces
fi

echo "" | sudo tee --append /etc/network/interfaces > /dev/null
echo "allow-hotplug wlan0" | sudo tee --append /etc/network/interfaces > /dev/null
echo "iface wlan0 inet static" | sudo tee --append /etc/network/interfaces > /dev/null
Expand All @@ -26,6 +25,8 @@ echo " broadcast 10.0.0.255" | sudo tee --append /etc/network/interfaces > /d
echo "iface wlan0 inet6 static" | sudo tee --append /etc/network/interfaces > /dev/null
echo " address fdfc::2" | sudo tee --append /etc/network/interfaces > /dev/null
echo " netmask 64" | sudo tee --append /etc/network/interfaces > /dev/null
echo "allow-hotplug eth0" | sudo tee --append /etc/network/interfaces > /dev/null
echo "iface eth0 inet dhcp" | sudo tee --append /etc/network/interfaces > /dev/null

# Enable packet forwarding
sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup
Expand Down Expand Up @@ -73,16 +74,28 @@ else
fi

# Configure DHCP with dnsmasq
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.backup
if [ -f /etc/dnsmasq.conf ]; then
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.backup
fi
sudo cp "$BASE_DIR/dnsmasq.conf" /etc/dnsmasq.conf
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.backup
sudo echo "" | sudo tee --append /etc/dhcpcd.conf > /dev/null
sudo echo "denyinterfaces wlan0" | sudo tee --append /etc/dhcpcd.conf > /dev/null


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not have random newlines everywhere.

if [ -f /etc/dhcpcd.conf ]; then
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.backup
sudo echo "" | sudo tee --append /etc/dhcpcd.conf > /dev/null
sudo echo "denyinterfaces wlan0" | sudo tee --append /etc/dhcpcd.conf > /dev/null
fi

# Configure IPv6 router advertisement with radvd
sudo cp "$BASE_DIR/radvd.conf" /etc/radvd.conf

# Enable hostapd service
if [ -f /etc/default/hostapd ]; then

sed '\?^DAEMON_CONF?d' /etc/default/hostapd | sudo tee /etc/default/hostapd > /dev/null
sudo echo DAEMON_CONF="/etc/hostapd.conf" | sudo tee --append /etc/default/hostapd > /dev/null
fi

sudo cp "$BASE_DIR/hostapd.service" /etc/systemd/system/hostapd.service
sudo systemctl daemon-reload
sudo systemctl enable hostapd.service
Expand Down
17 changes: 13 additions & 4 deletions scripts/install2
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ BOARD_REVISION="?"
CJDNS_BUILD_CMD="sudo Seccomp_NO=1 NO_NEON=1 ./do"
BOARD_HARDWARE=$(cat /proc/cpuinfo | grep Hardware | awk '{print $3}' | head -n 1)

ALLOW_HOSTAP=false #Flag for prompt of hostap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUPPORT_HOSTAP? The comment for the flag should be whether the board supports hostapd, the prompt is just the effect of the flag being true.


# Possibly use /sys/firmware/devicetree/base/model
if [[ "$BOARD_HARDWARE" == 'Allwinner' || "$BOARD_HARDWARE" == 'Generic' ]]; then
if [[ "$BOARD_HARDWARE" == 'Allwinner' || "$BOARD_HARDWARE" == 'Generic' ]]; then
BOARD_FAMILY="Orange Pi"
BOARD_NAME=$(grep BOARD_NAME /etc/armbian-image-release | awk -F \= '{print $2}' | tr -d \" | sed 's/Orange Pi //g')
BOARD_REVISION="experimental"
if [[ '$BOARD_NAME' == 'Zero' ]]; then
if [[ "$BOARD_NAME" == "Zero" ]]; then
CJDNS_BUILD_CMD="sudo Seccomp_NO=1 CFLAGS=\"-s -static -Wall -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -fomit-frame-pointer -marm\" ./do"
if [ "$(lsmod | grep xradio_wlan)" ]; then #If board already support xradio, let it install hostapd
ALLOW_HOSTAP=true
fi
else
CJDNS_BUILD_CMD="sudo Seccomp_NO=1 CFLAGS=\"-s -static -Wall -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -fomit-frame-pointer -marm\" ./do"
fi
Expand All @@ -41,6 +46,7 @@ else
elif [[ $BOARD_REVISION == *"a02082"* || $BOARD_REVISION == *"a22082"* ]]; then
BOARD_NAME="3"
CJDNS_BUILD_CMD="sudo NO_TEST=1 CFLAGS=\"-march=armv8-a+crc -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard\" ./do"
ALLOW_HOSTAP=true #has onboard wifi, use it
fi
fi

Expand All @@ -61,6 +67,9 @@ if [[ $BOARD_FAMILY == "Orange Pi" ]]; then
wget http://apt.armbian.com/pool/main/l/linux-4.10.0-sun8i/linux-image-dev-sun8i_5.26_armhf.deb
sudo dpkg -i linux-image-dev-sun8i_5.26_armhf.deb
rm -rf linux-image-dev-sun8i_5.26_armhf.deb
ALLOW_HOSTAP=true #downgrading kernel, allow hostapd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The downgrade is still needed here?

else
ALLOW_HOSTAP=false #Zero is not downgraded from broken kernel, dont allow hostap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't

fi
fi
fi
Expand All @@ -78,7 +87,7 @@ if [ -z "$WITH_MESH_POINT" -o "$WITH_MESH_POINT" != "true" -a "$WITH_MESH_POINT"
WITH_MESH_POINT=true
fi
fi
if [[ $BOARD_REVISION == *"a02082"* || $BOARD_REVISION == *"a22082"* ]] && [ -z "$WITH_WIFI_AP" -o "$WITH_WIFI_AP" != "true" -a "$WITH_WIFI_AP" != "false" ]; then
if [[ "$ALLOW_HOSTAP" == "true" ]] && [ -z "$WITH_WIFI_AP" -o "$WITH_WIFI_AP" != "true" -a "$WITH_WIFI_AP" != "false" ]; then
read -p "Configure WiFi Access Point (Y/n)? " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Nn]$ ]]; then
Expand Down Expand Up @@ -246,7 +255,7 @@ if [ ! -z "$WITH_MESH_POINT" -a "$WITH_MESH_POINT" == "true" ]; then
fi

# WiFi Access Point on RPi3
if [[ $BOARD_REVISION == *"a02082"* || $BOARD_REVISION == *"a22082"* ]] && [ ! -z "$WITH_WIFI_AP" -a "$WITH_WIFI_AP" == "true" ]; then
if [[ "$ALLOW_HOSTAP" == "true" ]] && [ ! -z "$WITH_WIFI_AP" -a "$WITH_WIFI_AP" == "true" ]; then
source hostapd/install
fi

Expand Down