WIP of mesh

This commit is contained in:
Ariel Sosnovsky committed 2024-02-14 16:00:49 -05:00
1 parent ce9c9c1a8b
commit 327f4e40da
6 files changed
+215 -1

No files matched your search

+3 -1
View File
@@ -13,4 +13,6 @@ devenv.local.nix
# Terraform
*.tfvars
.terraform
.terraform
os/routers/openwrt-mesh/.env
.DS_Store
+46
View File
@@ -0,0 +1,46 @@
#!/bin/sh
BASE_PATH=$(realpath "${BASH_SOURCE[0]}" | xargs dirname)
pushd "$BASE_PATH"
mode=${1:-"main"}
host=${2:-"root@192.168.1.1"}
file_name="create-${mode}.sh"
dotenv_file_name=".env"
if [ ! -f "${file_name}" ]; then
echo "Invalid Mode ${mode}!"
echo "Please use 'main' or 'ap'"
exit 1
fi
if [ ! -f "${dotenv_file_name}" ]; then
echo "Missing dotenv file!"
echo "Please create a ${dotenv_file_name} in $BASE_PATH!"
exit 1
fi
echo "mode=${mode}"
echo "host=${host}"
read -p "Continue? [Y/N]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Continuing..."
else
echo "Stopping!"
exit 1
fi
scp -O "$file_name" "$host:/tmp/update-script.sh"
scp -O "$dotenv_file_name" "$host:/tmp/.env"
ssh -t "$host" <<EOF
set -e
echo "chmod +x /tmp/update-script.sh"
chmod +x /tmp/update-script.sh
echo "export \$(cat /tmp/.env | xargs -0)"
export \$(cat /tmp/.env | xargs -0)
echo "/tmp/update-script.sh"
/tmp/update-script.sh
EOF
@@ -0,0 +1,9 @@
#!/bin/bash
opkg update --no-check-certificate
opkg remove wpad-basic-*
opkg install --force-overwrite \
--no-check-certificate \
wpad-openssl
uci set system.@system[0].hostname="${HOSTNAME}"
uci commit
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
HOSTNAME=${1:-$HOSTNAME}
echo "Configuring AP to $HOSTNAME"
n=5
while [ "$n" -gt 0 ]; do
echo "Starting in $n..."
sleep 1
n=$(( n - 1 ))
done
for i in firewall dnsmasq odhcpd; do
if /etc/init.d/"$i" enabled; then
/etc/init.d/"$i" disable
/etc/init.d/"$i" stop
fi
done
uci set network.lan.proto='dhcp'
uci delete network.wan
uci delete network.wan6
uci delete network.lan.ipaddr
uci delete network.lan.netmask
mv /etc/config/firewall /etc/config/firewall.unused
reboot
+80
View File
@@ -0,0 +1,80 @@
#!/bin/ash
# Turn an OpenWrt dumb access point into a Wi-fi mesh point
# ######################
# you may customize this
# ######################
MESH_NAME="kososvsky-mesh"
MESH_RADIO=radio0
MESH_CHANNEL=1
WIFI_NAME="kososvsky-main"
WIFI_RADIO=radio1
WIFI_CHANNEL=36
WIFI_MOBDOMAIN='3333'
if [ -z ${MESH_PWD} ]; then
echo "Missing 'MESH_PWD'"
exit 1
else
echo "MESH_NAME = ${MESH_NAME}"
echo "MESH_PWD = ${MESH_PWD}"
fi
if [ -z ${WIFI_PWD} ]; then
echo "Missing 'WIFI_PWD'"
exit 1
else
echo "WIFI_NAME = ${WIFI_NAME}"
echo "WIFI_PWD = ${WIFI_PWD}"
fi
n=5
while [ "$n" -gt 0 ]; do
echo "Starting in $n..."
sleep 1
n=$(( n - 1 ))
done
# install the wpad mesh package
opkg update
opkg install --force-overwrite wpad-mesh-openssl
# delete the "OpenWrt" radios
uci delete wireless.default_radio0
uci delete wireless.default_radio1
# create the mesh Wifi
uci set wireless.wifinet0=wifi-iface
uci set wireless.wifinet0.device=$MESH_RADIO
uci set wireless.wifinet0.mode='mesh'
uci set wireless.wifinet0.encryption='sae'
uci set wireless.wifinet0.mesh_id=$MESH_NAME
uci set wireless.wifinet0.mesh_fwding='1'
uci set wireless.wifinet0.mesh_rssi_threshold='0'
uci set wireless.wifinet0.key=$MESH_PWD
uci set wireless.wifinet0.network='lan'
uci set "wireless.$MESH_RADIO.channel"=$MESH_CHANNEL
uci delete "wireless.$MESH_RADIO.disabled"
# create the AP Wifi
uci set wireless.wifinet1=wifi-iface
uci set wireless.wifinet1.device=$WIFI_RADIO
uci set wireless.wifinet1.mode='ap'
uci set wireless.wifinet1.ssid=$WIFI_NAME
uci set wireless.wifinet1.encryption='psk2'
uci set wireless.wifinet1.key=$WIFI_PWD
uci set wireless.wifinet1.ieee80211r='1'
uci set wireless.wifinet1.mobility_domain=$WIFI_MOBDOMAIN
uci set wireless.wifinet1.ft_over_ds='0'
uci set wireless.wifinet1.ft_psk_generate_local='1'
uci set wireless.wifinet1.network='lan'
uci set "wireless.$WIFI_RADIO.channel"=$WIFI_CHANNEL
uci delete "wireless.$WIFI_RADIO.disabled"
uci commit
wifi down
/etc/init.d/wpad restart
wifi up
+48
View File
@@ -0,0 +1,48 @@
#!/bin/sh
MESH_PWD=$(echo $MESH_PWD | tr -d '"')
WIFI_PWD=$(echo $WIFI_PWD | tr -d '"')
output_file=${1:-"/etc/config/wireless"}
echo "writing to $output_file"
cat << EOF >> "$output_file"
config wifi-iface 'mesh'
option device 'radio0'
option disabled '0'
option mode 'mesh'
option ifname 'mesh0'
option network 'lan'
option mesh_id 'kosovsky-mesh'
option encryption 'sae'
option key '${MESH_PWD}'
option mesh_fwding '1'
option mesh_rssi_threshold '0'
config wifi-iface 'wifi5g'
option ssid 'kosovsky-main'
option disabled '0'
option device 'radio2'
option mode 'ap'
option network 'lan'
option encryption 'psk2'
option key '${WIFI_PWD}'
option ieee80211r '1'
option mobility_domain '7da1'
option ft_over_ds '0'
config wifi-iface 'wifi2g'
option ssid 'kosovsky-main'
option disabled '0'
option device 'radio1'
option mode 'ap'
option network 'lan'
option encryption 'psk2'
option key '${WIFI_PWD}'
option ieee80211r '1'
option mobility_domain '3333'
option ft_over_ds '0'
option ft_psk_generate_local '1'
EOF