From 286e5ce814710e23219e21fd0d718141cfaf5a34 Mon Sep 17 00:00:00 2001 From: Jakob Olsson Date: Fri, 18 Aug 2023 14:23:07 +0200 Subject: [PATCH] map-controller: update default config and add uci-defaults generation --- map-controller/files/etc/config/mapcontroller | 83 +++++++++++-------- .../files/etc/uci-defaults/99-mapcntlr | 18 ++++ 2 files changed, 68 insertions(+), 33 deletions(-) create mode 100644 map-controller/files/etc/uci-defaults/99-mapcntlr diff --git a/map-controller/files/etc/config/mapcontroller b/map-controller/files/etc/config/mapcontroller index 00c4c11d4..9295ebbf1 100644 --- a/map-controller/files/etc/config/mapcontroller +++ b/map-controller/files/etc/config/mapcontroller @@ -1,5 +1,5 @@ config controller 'controller' - option enabled '0' + option enabled '1' # may be modified by other package start-up scripts (i.e. map-agent) option profile '4' option registrar '2 5 6' option debug '0' @@ -28,39 +28,58 @@ config sta_steering option report_rcpi_threshold_5g '96' option report_rcpi_threshold_6g '96' -#config ap -# option band '2' -# option encryption 'sae-mixed' -# option vid '1' -# option ssid 'IOWRT-2.4GHz' -# option encryption 'sae-mixed' -# option key '1234567890' +################### +# Default AP sections credentials will by updated +# by uci-defaults script 99-mapcntlr +################### -#config ap -# option band '5' -# option type 'fronthaul' -# option vid '1' -# option ssid 'IOWRT-5GHz' -# option encryption 'sae-mixed' -# option key '1234567890' +config ap + option band '5' + option ssid '$DEVICE_MANUFACTURER-$BASEMAC_ADDR' + option encryption 'sae-mixed' + option key '$WIFI_FH_KEY' + option vid '1' + option type 'fronthaul' -#config ap -# option band '2' -# option type 'backhaul' -# option vid '1' -# list disallow_bsta '0' -# option ssid 'MAP-BH-2.4GHz' -# option encryption 'sae' -# option key '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZYZ0' +config ap + option band '2' + option ssid '$DEVICE_MANUFACTURER-$BASEMAC_ADDR' + option encryption 'sae-mixed' + option key '$WIFI_FH_KEY' + option vid '1' + option type 'fronthaul' -#config ap -# option band '5' -# option type 'backhaul' -# option vid '1' -# list disallow_bsta '0' -# option ssid 'MAP-BH-5GHz' -# option encryption 'sae' -# option key '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZYZ0' +config ap + option band '6' + option ssid '$DEVICE_MANUFACTURER-$BASEMAC_ADDR' + option encryption 'sae' + option key '$WIFI_FH_KEY' + option vid '1' + option type 'fronthaul' + +config ap + option band '5' + option ssid 'MAP-$BASEMAC_ADDR-BH-5GHz' + option encryption 'sae' + option key '$WIFI_BH_KEY' + option type 'backhaul' + option vid '1' + +config ap + option band '2' + option ssid 'MAP-$BASEMAC_ADDR-BH-2.4GHz' + option encryption 'sae' + option key '$WIFI_BH_KEY' + option type 'backhaul' + option vid '1' + +config ap + option band '6' + option ssid 'MAP-$BASEMAC_ADDR-BH-6GHz' + option encryption 'sae' + option key '$WIFI_BH_KEY' + option type 'backhaul' + option vid '1' # node and radio sections (per node) are auto # generated per Multi-AP Agent in the network @@ -71,8 +90,6 @@ config sta_steering # option backhaul_ul_macaddr '00:00:00:00:00:00' # option backhaul_dl_macaddr '00:00:00:00:00:00' # option backhaul_type 'none' -# option primary_vid '1' -# option primary_pcp '0' # option report_sta_assocfails '0' # option report_sta_assocfails_rate '0' # option report_metric_periodic '0' diff --git a/map-controller/files/etc/uci-defaults/99-mapcntlr b/map-controller/files/etc/uci-defaults/99-mapcntlr new file mode 100644 index 000000000..cf44f0260 --- /dev/null +++ b/map-controller/files/etc/uci-defaults/99-mapcntlr @@ -0,0 +1,18 @@ +#!/bin/sh + +. /etc/device_info + +WIFI_BH_KEY=$(openssl rand -rand /dev/urandom -hex 64 2>/dev/null | openssl dgst -hex -sha256 | cut -d " " -f 2) +WIFI_BH_KEY=${WIFI_BH_KEY::-1} + +BASEMAC_ADDR="$(fw_printenv -n ethaddr | tr -d ':')" +[ ${#BASEMAC_ADDR} -eq 12 ] || BASEMAC_ADDR="$(db -q get device.deviceinfo.BaseMACAddress | tr -d ':')" + +WIFI_FH_KEY="$(db get hw.board.wpa_key)" +WIFI_FH_KEY="${WIFI_FH_KEY:-1234567890}" + +sed -i -e "s/\$BASEMAC_ADDR/$BASEMAC_ADDR/g" \ + -e "s/\$WIFI_FH_KEY/$WIFI_FH_KEY/g" \ + -e "s/\$WIFI_BH_KEY/$WIFI_BH_KEY/g" \ + -e "s/\$DEVICE_MANUFACTURER/$DEVICE_MANUFACTURER/g" \ + /etc/config/mapcontroller 2>/dev/null