diff --git a/README.md b/README.md index bbdf70b1f..bf212fb25 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,19 @@ [![Build Status](https://travis-ci.org/tomeshnet/prototype-cjdns-pi.svg?branch=master)](https://travis-ci.org/tomeshnet/prototype-cjdns-pi) -The following instructions will help you set up an encrypted mesh network on Raspberry Pi's. It takes about 5 minutes to set up a node with the Pi 3. Obviously, to have a mesh you will need more than one node. +The following instructions will help you set up an encrypted mesh network on Raspberry Pi's. It takes about 15 minutes to set up a node with the Pi 3. Obviously, to have a mesh you will need more than one node. + +Many models of Orange Pi hardware running [Armbian](https://www.armbian.com/) are also supported. The same installation steps can be followed, except you would flash the SD card with Armbian instead of Raspbian. See [Hardware Table](#hardware-table) for the full list of supported hardware. ## Set Up -(Note: Latest version is based on Stretch and is currently a WIP. Please continue to use Jessie) 1. Make sure you have the following items: - * A Raspberry Pi Zero, 1, 2, or 3 (Pi 3 recommended) + * Raspberry Pi Zero, 1, 2, 3 (Pi 3 recommended), or for advanced users other [compatible hardware](#hardware-table) * An SD card that works with the Pi * **Optional:** A USB WiFi adapter with [802.11s Mesh Point](https://github.com/o11s/open80211s/wiki/HOWTO) support, such as the [TP-LINK TL-WN722N](http://www.tp-link.com/en/products/details/TL-WN722N.html) or [Toplinkst TOP-GS07](https://github.com/tomeshnet/documents/blob/master/technical/20170208_mesh-point-with-topgs07-rt5572.md) -1. Flash the SD card with [Raspbian Jessie Lite](https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-07-05/2017-07-05-raspbian-jessie-lite.zip) +1. Flash the SD card with [Raspbian Stretch Lite](https://www.raspberrypi.org/downloads/raspbian/). 1. Create an empty file named **ssh** to enable SSH when the Pi boots: @@ -38,7 +39,7 @@ The following instructions will help you set up an encrypted mesh network on Ras The installation script can also install many optional features such as distributed applications and network analysis tools that are useful but non-essential to run a node. You can use flags to selectively enable them, or use the following command to install all optional features: ``` - $ wget https://raw.githubusercontent.com/tomeshnet/prototype-cjdns-pi/master/scripts/install && chmod +x install && WITH_MESH_POINT=true WITH_WIFI_AP=true WITH_IPFS=true WITH_PROMETHEUS_NODE_EXPORTER=true WITH_PROMETHEUS_SERVER=true WITH_GRAFANA=true WITH_EXTRA_TOOLS=true ./install + $ wget https://raw.githubusercontent.com/tomeshnet/prototype-cjdns-pi/master/scripts/install && chmod +x install && WITH_MESH_POINT=true WITH_WIFI_AP=true WITH_IPFS=true WITH_PROMETHEUS_NODE_EXPORTER=true WITH_PROMETHEUS_SERVER=true WITH_GRAFANA=true WITH_H_DNS=true WITH_H_NTP=true WITH_FAKE_HWCLOCK=true WITH_EXTRA_TOOLS=true ./install ``` ## Optional Features @@ -51,6 +52,9 @@ The following instructions will help you set up an encrypted mesh network on Ras | `WITH_PROMETHEUS_NODE_EXPORTER` | **9100**: Node Exporter UI | Set to `true` if you want to install [Prometheus Node Exporter](https://github.com/prometheus/node_exporter) to report network metrics. | | `WITH_PROMETHEUS_SERVER` | **9090**: Prometheus Server UI | Set to `true` if you want to install [Prometheus Server](https://github.com/prometheus/prometheus) to collect network metrics. *Requires Prometheus Node Exporter.* | | `WITH_GRAFANA` | **3000**: Grafana UI (login: admin/admin) | Set to `true` if you want to install [Grafana](https://grafana.com) to display network metrics. *Requires Prometheus Server.* | +| `WITH_H_DNS` | None | Set to `true` if you want to use Hyperboria-compatible DNS servers: `fc4d:c8e5:9efe:9ac2:8e72:fcf7:6ce8:39dc` and `fc6e:691e:dfaa:b992:a10a:7b49:5a1a:5e09` | +| `WITH_H_NTP` | None | Set to `true` if you want to use a Hyperboria-compatible NTP server: `fc4d:c8e5:9efe:9ac2:8e72:fcf7:6ce8:39dc` | +| `WITH_FAKE_HWCLOCK` | None | Set to `true` if you want to force hwclock to store its time every 5 minutes. | | `WITH_EXTRA_TOOLS` | None | Set to `true` if you want to install non-essential tools useful for network analysis: vim socat oping bmon iperf3 | If you are connected to the WiFi Access Point, all HTTP services are available via `http://10.0.0.1:PORT` as well as the cjdns IPv6. To connect with the cjdns address, first note your node's fc00::/8 address from `status`, then navigate to `http://[fcaa:bbbb:cccc:dddd:eeee:0000:1111:2222]:PORT` from your browser. @@ -83,18 +87,19 @@ We are adding support for [Orange Pi](http://www.orangepi.org/) boards and have ## Hardware Table -Following is a list of hardware tested with the install. - -| Hardware | Base OS | CJDNS Bench~ | USB | Ethernet| Notes | -| :-------------------------|:----------------|:--------------|:-----|:--------|:-----------------| -| Raspberry Pi 1 A+ | [Raspbian Jessie Lite](https://www.raspberrypi.org/downloads/raspbian/) | 35K | 1 | None | | -| Raspberry Pi 1 B+ | [Raspbian Jessie Lite](https://www.raspberrypi.org/downloads/raspbian/) | 35K | 2 | 10/100 | | -| Raspberry Pi 3 | [Raspbian Jessie Lite](https://www.raspberrypi.org/downloads/raspbian/) | | 2 | 10/100 | | -| Raspberry Pi Zero | [Raspbian Jessie Lite](https://www.raspberrypi.org/downloads/raspbian/) | | 1 | 10/100 | | -| Orange Pi Lite | [Armbian Nightly](https://dl.armbian.com/orangepilite/nightly/) | 126K | 2 | None | | -| Orange Pi One | [Armbian Nightly](https://dl.armbian.com/orangepione/nightly/) | 131K | 1 | 10/100 | | -| Orange Pi Zero | [Armbian Nightly](https://dl.armbian.com/orangepizero/nightly/) | 70K | 1(+2*) | 10/100 | *Additional USB available via headers | -| Orange Pi Zero Plus 2 H5 | [Armbian Nightly](https://dl.armbian.com/orangepizeroplus2-h5/nightly/) | 142K | 0(+2*) | None | *USB available via headers | +List of tested hardware: + +| Hardware | Base OS | [CJDNS Benchmark](https://github.com/phillymesh/cjdns-optimizations) (salsa20/poly1305, switching) | USB | Ethernet | Notes | +| :-------------------------|:----------------|:---------------------------------------------------------------------------------------------------|:----|:---------|:---------| +| Raspberry Pi 3 | [Raspbian Lite](https://www.raspberrypi.org/downloads/raspbian/) | 350k, 100k | 2 | 10/100 | | +| Raspberry Pi 2 | [Raspbian Lite](https://www.raspberrypi.org/downloads/raspbian/) | 150k, 50k | 2 | 10/100 | | +| Raspberry Pi 1 A+ | [Raspbian Lite](https://www.raspberrypi.org/downloads/raspbian/) | 35k, - | 1 | None | | +| Raspberry Pi 1 B+ | [Raspbian Lite](https://www.raspberrypi.org/downloads/raspbian/) | 35k, - | 2 | 10/100 | | +| Raspberry Pi Zero | [Raspbian Lite](https://www.raspberrypi.org/downloads/raspbian/) | 68k, 30k | 1* | None | *Need OTG Cable | +| Orange Pi Lite | [Armbian Nightly](https://dl.armbian.com/orangepilite/nightly/) | 198k, 76k | 2 | None | | +| Orange Pi One | [Armbian Nightly](https://dl.armbian.com/orangepione/nightly/) | 198k, 76k | 1 | 10/100 | | +| Orange Pi Zero | [Armbian Nightly](https://dl.armbian.com/orangepizero/nightly/) | 148k, 56k | 1 (+2*) | 10/100 | *Additional USB available via headers | +| Orange Pi Zero Plus 2 H5 | [Armbian Nightly](https://dl.armbian.com/orangepizeroplus2-h5/nightly/) | 142k, 92K | 0 (+2*) | None | *USB available via headers | ## Development diff --git a/scripts/fake-hwclock/install b/scripts/fake-hwclock/install new file mode 100755 index 000000000..e6e55c2d2 --- /dev/null +++ b/scripts/fake-hwclock/install @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e + +BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Install fake-hwclock +if [ ! -x "$(command -v fake-hwclock)" ]; then + sudo apt-get install fake-hwclock -y +fi + +# Configure crontab to run fake-hwclock every 5 minutes +sudo sed -i '/fake-hwclock/d' /etc/crontab +echo "*/5 * * * * root fake-hwclock" | sudo tee --append /etc/crontab > /dev/null diff --git a/scripts/fake-hwclock/uninstall b/scripts/fake-hwclock/uninstall new file mode 100755 index 000000000..b8d736186 --- /dev/null +++ b/scripts/fake-hwclock/uninstall @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e + +sudo sed -i '/fake-hwclock/d' /etc/crontab \ No newline at end of file diff --git a/scripts/h-dns/install b/scripts/h-dns/install new file mode 100755 index 000000000..3ce4a7533 --- /dev/null +++ b/scripts/h-dns/install @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e + +H_DNS_SERVER_0="fc4d:c8e5:9efe:9ac2:8e72:fcf7:6ce8:39dc" +H_DNS_SERVER_1="fc6e:691e:dfaa:b992:a10a:7b49:5a1a:5e09" + +BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Configure Hyperboria DNS +sudo sed -i '/dns-nameservers /d' /etc/network/interfaces +echo "" | sudo tee --append /etc/network/interfaces > /dev/null +echo "dns-nameservers ${H_DNS_SERVER_0} ${H_DNS_SERVER_1}" | sudo tee --append /etc/network/interfaces > /dev/null diff --git a/scripts/h-dns/uninstall b/scripts/h-dns/uninstall new file mode 100755 index 000000000..663149525 --- /dev/null +++ b/scripts/h-dns/uninstall @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e + +sudo sed -i '/dns-nameservers /d' /etc/network/interfaces \ No newline at end of file diff --git a/scripts/h-ntp/install b/scripts/h-ntp/install new file mode 100755 index 000000000..c97a15fb8 --- /dev/null +++ b/scripts/h-ntp/install @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -e + +H_NTP_SERVER="fc4d:c8e5:9efe:9ac2:8e72:fcf7:6ce8:39dc" + +BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Install NTP +if [ ! -x "$(command -v ntpd)" ]; then + sudo apt-get install ntp -y +fi + +# Configure Hyperboria NTP +sudo sed -i '/pool /d' /etc/ntp.conf +echo "pool -6 ${H_NTP_SERVER} iburst" | sudo tee --append /etc/ntp.conf > /dev/null diff --git a/scripts/h-ntp/uninstall b/scripts/h-ntp/uninstall new file mode 100755 index 000000000..17bb8767a --- /dev/null +++ b/scripts/h-ntp/uninstall @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e + +sudo sed -i '/pool /d' /etc/ntp.conf \ No newline at end of file diff --git a/scripts/hostapd/dnsmasq.conf b/scripts/hostapd/dnsmasq.conf index bbb9884e1..16b383b10 100644 --- a/scripts/hostapd/dnsmasq.conf +++ b/scripts/hostapd/dnsmasq.conf @@ -1,2 +1,3 @@ interface=wlan0 dhcp-range=10.0.0.2,10.0.0.127,255.255.255.0,12h +bind-interfaces diff --git a/scripts/hostapd/install b/scripts/hostapd/install index 70ea030c7..a026932d1 100755 --- a/scripts/hostapd/install +++ b/scripts/hostapd/install @@ -4,16 +4,22 @@ 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 +# Create radvd.conf before installing radvd, installation fails without it +if ! [ -f /etc/radvd.conf ]; then + sudo cp "$BASE_DIR/radvd.conf" /etc/radvd.conf fi +# Install packages to run IEEE 802.11 Access Point +sudo apt-get install hostapd radvd dnsmasq iptables -y + # Configure wlan0 interface -sudo cp /etc/network/interfaces /etc/network/interfaces.backup -START=$(grep -n "allow-hotplug wlan0" /etc/network/interfaces | awk '{ print $1 }' FS=':') -END=$(expr $START + 3) -sudo sed -i "${START},${END}d" /etc/network/interfaces +sudo mv /etc/network/interfaces /etc/network/interfaces.bak +sudo touch /etc/network/interfaces + +echo "source-directory /etc/network/interfaces.d" | sudo tee --append /etc/network/interfaces > /dev/null +echo "" | sudo tee --append /etc/network/interfaces > /dev/null +echo "auto lo" | sudo tee --append /etc/network/interfaces > /dev/null +echo "iface lo inet loopback" | sudo tee --append /etc/network/interfaces > /dev/null 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 @@ -24,9 +30,12 @@ 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 "" | 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 +sudo cp /etc/sysctl.conf /etc/sysctl.conf.bak sudo sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf sudo sed -i 's/#net.ipv6.conf.all.forwarding=1/net.ipv6.conf.all.forwarding=1/' /etc/sysctl.conf @@ -71,17 +80,30 @@ 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.bak +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 + +if [ -f /etc/dhcpcd.conf ]; then + sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.bak + 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 +sudo systemctl daemon-reload +sudo systemctl enable radvd.service +sudo systemctl start radvd.service # 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 -sudo systemctl start hostapd.service \ No newline at end of file +sudo systemctl start hostapd.service diff --git a/scripts/hostapd/uninstall b/scripts/hostapd/uninstall index 68f8cc0f7..7f4e0b3d7 100755 --- a/scripts/hostapd/uninstall +++ b/scripts/hostapd/uninstall @@ -6,17 +6,17 @@ set -e sudo systemctl disable hostapd.service 2>/dev/null || true sudo systemctl stop hostapd.service 2>/dev/null || true sudo systemctl daemon-reload -if [ -f "/etc/network/interfaces.backup" ]; then - sudo mv /etc/network/interfaces.backup /etc/network/interfaces +if [ -f "/etc/network/interfaces.bak" ]; then + sudo mv /etc/network/interfaces.bak /etc/network/interfaces fi -if [ -f "/etc/sysctl.conf.backup" ]; then - sudo mv /etc/sysctl.conf.backup /etc/sysctl.conf +if [ -f "/etc/sysctl.conf.bak" ]; then + sudo mv /etc/sysctl.conf.bak /etc/sysctl.conf fi -if [ -f "/etc/dnsmasq.conf.backup" ]; then - sudo mv /etc/dnsmasq.conf.backup /etc/dnsmasq.conf +if [ -f "/etc/dnsmasq.conf.bak" ]; then + sudo mv /etc/dnsmasq.conf.bak /etc/dnsmasq.conf fi -if [ -f "/etc/dhcpcd.conf.backup" ]; then - sudo mv /etc/dhcpcd.conf.backup /etc/dhcpcd.conf +if [ -f "/etc/dhcpcd.conf.bak" ]; then + sudo mv /etc/dhcpcd.conf.bak /etc/dhcpcd.conf fi sudo rm -f /etc/radvd.conf sudo rm -f /etc/hostapd/hostapd.conf diff --git a/scripts/hostapd/wpa-eap/hostapd.conf b/scripts/hostapd/wpa-eap/hostapd.conf index 5b96de8c1..1ff3005af 100644 --- a/scripts/hostapd/wpa-eap/hostapd.conf +++ b/scripts/hostapd/wpa-eap/hostapd.conf @@ -1,6 +1,6 @@ interface=wlan0 hw_mode=g -channel=10 +channel=11 auth_algs=1 wpa=3 wpa_key_mgmt=WPA-EAP diff --git a/scripts/hostapd/wpa-psk/hostapd.conf b/scripts/hostapd/wpa-psk/hostapd.conf index 8fc343784..16e16b0b4 100644 --- a/scripts/hostapd/wpa-psk/hostapd.conf +++ b/scripts/hostapd/wpa-psk/hostapd.conf @@ -1,6 +1,6 @@ interface=wlan0 hw_mode=g -channel=10 +channel=11 auth_algs=1 wpa=2 wpa_key_mgmt=WPA-PSK diff --git a/scripts/install b/scripts/install index cff34c8b8..6b60cb83f 100755 --- a/scripts/install +++ b/scripts/install @@ -12,7 +12,7 @@ if [ -z "$TAG_PROTOTYPE_CJDNS_PI" ]; then TAG_PROTOTYPE_CJDNS_PI=master fi -if ! [ -z "`ps xa | grep dpkg | grep -v grep`" ]; then +if ! [ -z "`ps xa | awk '{print $5}' | grep dpkg | grep -v grep`" ]; then echo -e "\e[1;31mDPKG is running in the background.\e[0m" read -p "Would you like to KILL it to continue (Y/n)? " -n 1 -r echo "" diff --git a/scripts/install2 b/scripts/install2 index 57f91180d..c269c5ebf 100755 --- a/scripts/install2 +++ b/scripts/install2 @@ -2,7 +2,7 @@ set -e -TAG_CJDNS=cjdns-v19.1 +TAG_CJDNS=186169f9a8631633795e4e9d70c501519a7800f4 # Get board information and set flags accordingly BOARD_FAMILY="Unknown" @@ -11,23 +11,32 @@ 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) +# Flag to identify if board can support on-board AP +SUPPORT_HOSTAP=false + # 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="Generic" + BOARD_NAME=$(grep BOARD_NAME /etc/armbian-image-release | awk -F \= '{print $2}' | tr -d \" | sed 's/Orange Pi //g') BOARD_REVISION="experimental" - CJDNS_BUILD_CMD="sudo Seccomp_NO=1 CFLAGS=\"-s -static -Wall -mfpu=neon -mcpu=cortex-a7 -mtune=cortex-a7 -fomit-frame-pointer -marm\" ./do" + if [[ "$BOARD_NAME" == "Zero" ]]; then + # AP is supported if board already supports XRadio + if [ "$(lsmod | grep xradio_wlan)" ]; then + SUPPORT_HOSTAP=true + fi + fi + 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" elif [[ "$BOARD_HARDWARE" == 'sun50iw1p1' ]]; then BOARD_FAMILY="Orange Pi" - BOARD_NAME="H5" + BOARD_NAME=$(grep BOARD_NAME /etc/armbian-image-release | awk -F \= '{print $2}' | tr -d \" | sed 's/Orange Pi //g') BOARD_REVISION="experimental" CJDNS_BUILD_CMD="sudo Seccomp_NO=1 CFLAGS=\"-s -static -Wall -march=armv8-a+crc+crypto -mcpu=cortex-a53 -ftree-vectorize -mtune=cortex-a53 -fomit-frame-pointer\" ./do" else BOARD_FAMILY="Raspberry Pi" BOARD_REVISION=`sed -rn 's/Revision\s+\:\s+([0-9a-z_\-\s\,\(\)]+)/\1/p' /proc/cpuinfo` - if [[ $BOARD_REVISION == *"900092"* || $BOARD_REVISION == *"900093"* ]]; then + if [[ $BOARD_REVISION == *"900092"* || $BOARD_REVISION == *"900093"* || $BOARD_REVISION == *"9000c1"* ]]; then BOARD_NAME="Zero" - CJDNS_BUILD_CMD="sudo Seccomp_NO=1 NO_NEON=1 CFLAGS=\"-s -static -Wall\" ./do" + CJDNS_BUILD_CMD="sudo Seccomp_NO=1 NO_NEON=1 CFLAGS=\"-s -static -Wall -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard\" ./do" elif [[ $BOARD_REVISION == *"00"* ]]; then BOARD_NAME="1" CJDNS_BUILD_CMD="sudo Seccomp_NO=1 NO_NEON=1 NO_TEST=1 CFLAGS=\"-s -static -Wall\" ./do" @@ -36,7 +45,10 @@ else CJDNS_BUILD_CMD="sudo Seccomp_NO=1 CFLAGS=\"-s -static -Wall -mfpu=neon -mcpu=cortex-a7 -mtune=cortex-a7 -fomit-frame-pointer -marm\" ./do" elif [[ $BOARD_REVISION == *"a02082"* || $BOARD_REVISION == *"a22082"* ]]; then BOARD_NAME="3" - CJDNS_BUILD_CMD="sudo Seccomp_NO=1 CFLAGS=\"-s -static -Wall -mfpu=neon -mcpu=cortex-a7 -mtune=cortex-a7 -fomit-frame-pointer -marm\" ./do" + CJDNS_BUILD_CMD="sudo CFLAGS=\"-march=armv8-a+crc -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard -O2\" ./do" + + # Raspberry Pi 3 has on-board WiFi that can be used as an AP + SUPPORT_HOSTAP=true fi fi @@ -47,16 +59,22 @@ sudo touch /etc/udev/rules.d/80-net-setup-link.rules # Set configurations specific to the board if [[ $BOARD_FAMILY == "Orange Pi" ]]; then - # Downgrade Kernel to re-enable XRadio in version 4.10 on Orange Pi Zero + # Downgrade kernel to enable XRadio in version 4.10 on Orange Pi Zero if ! [ -z "`uname -a | grep 4.11`" ]; then if ! [ -z "`cat /sys/bus/mmc/devices/mmc1:0001/mmc1:0001:1/uevent | grep SDIO_ID | grep 0020:2281`" ]; then - read -p "Downgrade Kernel to Enable XRadio on Pi Zero (Y/n)? " -n 1 -r + read -p "Downgrade kernel to enable XRadio on Orange Pi Zero (Y/n)? " -n 1 -r echo "" if ! [[ $REPLY =~ ^[Nn]$ ]]; then echo -e "\e[1;32mDowngrading Kernel...\e[0m" - wget http://apt.armbian.com/pool/main/l/linux-4.10.0-sun8i/linux-image-dev-sun8i_5.26_armhf.deb + wget https://github.com/darkdrgn2k/OrangePiXRadio/raw/master/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 + + # AP supported on downgraded kernel + SUPPORT_HOSTAP=true + else + # AP not supported without kernel downgrade + SUPPORT_HOSTAP=false fi fi fi @@ -74,7 +92,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 [[ "$SUPPORT_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 @@ -139,6 +157,39 @@ else # Skip because Prometheus Server is not installed WITH_GRAFANA=false fi +if [ -z "$WITH_H_DNS" -o "$WITH_H_DNS" != "true" -a "$WITH_H_DNS" != "false" ]; then + read -p "Configure Hyperboria-compatible Domain Name Servers (Y/n)? " -n 1 -r + echo "" + if [[ $REPLY =~ ^[Nn]$ ]]; then + echo -e "\e[1;31mDNS settings will be skipped\e[0m" + WITH_H_DNS=false + else + echo -e "\e[1;32mDNS settings will be configured\e[0m" + WITH_H_DNS=true + fi +fi +if [ -z "$WITH_H_NTP" -o "$WITH_H_NTP" != "true" -a "$WITH_H_NTP" != "false" ]; then + read -p "Configure Hyperboria-compatible Network Time Protocol server (Y/n)? " -n 1 -r + echo "" + if [[ $REPLY =~ ^[Nn]$ ]]; then + echo -e "\e[1;31mNTP settings will be skipped\e[0m" + WITH_H_NTP=false + else + echo -e "\e[1;32mNTP settings will be configured\e[0m" + WITH_H_NTP=true + fi +fi +if [ -z "$WITH_FAKE_HWCLOCK" -o "$WITH_FAKE_HWCLOCK" != "true" -a "$WITH_FAKE_HWCLOCK" != "false" ]; then + read -p "Configure Fake Hardware Clock to store time value every 5 minutes (Y/n)? " -n 1 -r + echo "" + if [[ $REPLY =~ ^[Nn]$ ]]; then + echo -e "\e[1;31mFake Hardware Clock will be skipped\e[0m" + WITH_FAKE_HWCLOCK_=false + else + echo -e "\e[1;32mFake Hardware Clock will be configured\e[0m" + WITH_FAKE_HWCLOCK=true + fi +fi if [ -z "$WITH_EXTRA_TOOLS" -o "$WITH_EXTRA_TOOLS" != "true" -a "$WITH_EXTRA_TOOLS" != "false" ]; then read -p "Install non-essential tools useful for network analysis (Y/n)? " -n 1 -r echo "" @@ -176,7 +227,9 @@ fi if ! [ -d "/opt/cjdns" ]; then here=`pwd` sudo git clone https://github.com/cjdelisle/cjdns.git /opt/cjdns - cd /opt/cjdns && sudo git checkout $TAG_CJDNS && cd $here + cd /opt/cjdns + sudo git checkout $TAG_CJDNS + cd $here fi # Build cjdns @@ -186,9 +239,8 @@ if ! [ -x "/opt/cjdns/cjdroute" ]; then fi # Install cjdns to /usr/bin -if ! [ -x "/usr/bin/cjdroute" ]; then - sudo cp /opt/cjdns/cjdroute /usr/bin/cjdroute -fi +sudo rm -f /usr/bin/cjdroute +sudo cp /opt/cjdns/cjdroute /usr/bin/cjdroute # Generate cjdns configurations if ! [ -f "/etc/cjdroute.conf" ]; then @@ -209,7 +261,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 [[ "$SUPPORT_HOSTAP" == "true" ]] && [ ! -z "$WITH_WIFI_AP" -a "$WITH_WIFI_AP" == "true" ]; then source hostapd/install fi @@ -233,6 +285,21 @@ if [ ! -x "$(command -v /usr/sbin/grafana-server)" ] && [ ! -z "$WITH_GRAFANA" - source grafana/install fi +# Configure Hyperboria DNS +if [ ! -z "$WITH_H_DNS" -a "$WITH_H_DNS" == "true" ]; then + source h-dns/install +fi + +# Configure Hyperboria NTP +if [ ! -z "$WITH_H_NTP" -a "$WITH_H_NTP" == "true" ]; then + source h-ntp/install +fi + +# Configure Fake Hardware Clock +if [ ! -z "$WITH_FAKE_HWCLOCK" -a "$WITH_FAKE_HWCLOCK" == "true" ]; then + source fake-hwclock/install +fi + # Non-essential extra tools if [ ! -z "$WITH_EXTRA_TOOLS" -a "$WITH_EXTRA_TOOLS" == "true" ]; then source extra-tools/install diff --git a/scripts/ipfs/uninstall b/scripts/ipfs/uninstall index 9d68d2da2..47f5c6d7e 100755 --- a/scripts/ipfs/uninstall +++ b/scripts/ipfs/uninstall @@ -22,6 +22,6 @@ if [ -d "~/.ipfs" ]; then fi # Remove HTTP to IPFS gateway -sudo rm /etc/nginx/sites-enabled/ipfs-http-gateway -sudo rm /etc/nginx/sites-available/ipfs-http-gateway -sudo systemctl restart nginx.service \ No newline at end of file +sudo rm -f /etc/nginx/sites-enabled/ipfs-http-gateway +sudo rm -f /etc/nginx/sites-available/ipfs-http-gateway +sudo systemctl restart nginx.service diff --git a/scripts/mesh-point/mesh b/scripts/mesh-point/mesh index 9d313090c..b9f8bed8b 100755 --- a/scripts/mesh-point/mesh +++ b/scripts/mesh-point/mesh @@ -36,22 +36,20 @@ fi # Shut down the mesh_dev interface sudo ifconfig $mesh_dev down -# Create mesh0 802.11s Mesh Point interface -if [ -z "$(iw dev | grep mesh0)" ]; then - sudo iw phy $mesh_phy interface add mesh0 type mp -fi +# Convert mesh_dev to 802.11s Mesh Point interface +sudo iw $mesh_dev set type mp -# Bring up the mesh0 interface -sudo ifconfig mesh0 up +# Bring up the mesh_dev interface +sudo ifconfig $mesh_dev up -# Optionally assign IPv4 address to the mesh0 interface -# sudo ifconfig mesh0 192.168.X.Y +# Optionally assign IPv4 address to the mesh_dev interface +# sudo ifconfig $mesh_dev 192.168.X.Y # Join the mesh network with radio in HT40+ htmode to enable 802.11n rates -sudo iw dev mesh0 mesh join MESH_NAME freq 2412 HT40+ +sudo iw dev $mesh_dev mesh join MESH_NAME freq 2412 HT40+ # Disable forwarding since we rely on cjdns to do routing and only uses Mesh Point as a point-to-point link -sudo iw dev mesh0 set mesh_param mesh_fwding=0 +sudo iw dev $mesh_dev set mesh_param mesh_fwding=0 # Restart cjdns sudo killall cjdroute diff --git a/scripts/status b/scripts/status index fe5ed37ee..1cc70c135 100755 --- a/scripts/status +++ b/scripts/status @@ -16,7 +16,14 @@ else echo -e "cjdns Service .............. $INACTIVE" fi if [ "$(which mesh)" ]; then - if [ "$(iw dev mesh0 info 2>/dev/null | grep 'type mesh point')" ] && [ "$(iw dev mesh0 info 2>/dev/null | grep 'channel')" ]; then + ints=$(iw dev | grep Interface | awk '{print $2}') + while read -r line; do + mp=$(iw dev $line info | grep "type mesh point") + if [ "$mp" ]; then + mpint=$line + fi + done <<< "$ints" + if [ -n "$mpint" ] && [ "$(ifconfig | grep $mpint)" ]; then echo -e "Mesh Interface ............... $ACTIVE" else echo -e "Mesh Interface ............. $INACTIVE"