From 327f4e40da2050f40a83765ecf4ecd4d507cf960 Mon Sep 17 00:00:00 2001 From: Ariel Sosnovsky Date: Wed, 14 Feb 2024 16:00:49 -0500 Subject: [PATCH] WIP of mesh --- .gitignore | 4 +- os/routers/openwrt-mesh/push.sh | 46 +++++++++++ .../openwrt-mesh/remote-scripts/common.sh | 9 +++ .../openwrt-mesh/remote-scripts/create-ap.sh | 29 +++++++ .../remote-scripts/create-main.sh | 80 +++++++++++++++++++ .../remote-scripts/gen-etc-wireless.sh | 48 +++++++++++ 6 files changed, 215 insertions(+), 1 deletion(-) create mode 100755 os/routers/openwrt-mesh/push.sh create mode 100644 os/routers/openwrt-mesh/remote-scripts/common.sh create mode 100755 os/routers/openwrt-mesh/remote-scripts/create-ap.sh create mode 100755 os/routers/openwrt-mesh/remote-scripts/create-main.sh create mode 100755 os/routers/openwrt-mesh/remote-scripts/gen-etc-wireless.sh diff --git a/.gitignore b/.gitignore index 7f5cc86..970b053 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,6 @@ devenv.local.nix # Terraform *.tfvars -.terraform \ No newline at end of file +.terraform +os/routers/openwrt-mesh/.env +.DS_Store diff --git a/os/routers/openwrt-mesh/push.sh b/os/routers/openwrt-mesh/push.sh new file mode 100755 index 0000000..e84a34f --- /dev/null +++ b/os/routers/openwrt-mesh/push.sh @@ -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" <> "$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 \ No newline at end of file