mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
sulu-vendorext: remove mldsync script
since changes via tr-181 do not trigger procd config reload trigger
This commit is contained in:
parent
d530ffa4ba
commit
a80713423c
1 changed files with 0 additions and 127 deletions
|
|
@ -1,127 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
START=97
|
||||
USE_PROCD=1
|
||||
|
||||
# Function to find the first available MLD ID
|
||||
find_available_mld_id() {
|
||||
# Get all MLD sections and their IDs
|
||||
for mld in $(uci show mapcontroller | grep "^mapcontroller.@mld\[" | cut -d'=' -f1); do
|
||||
mld_id=$(uci -q get "$mld.id")
|
||||
[ -z "$mld_id" ] && continue
|
||||
|
||||
# Check if any AP is using this MLD ID
|
||||
mld_in_use=0
|
||||
for ap in $(uci show mapcontroller | grep "^mapcontroller.@ap\[" | cut -d'=' -f1); do
|
||||
ap_mld_id=$(uci -q get "$ap.mld_id")
|
||||
if [ "$ap_mld_id" = "$mld_id" ]; then
|
||||
mld_in_use=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# If no AP is using this MLD ID, it's available
|
||||
if [ "$mld_in_use" -eq 0 ]; then
|
||||
echo "$mld_id"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# If we get here, no available MLD ID was found
|
||||
return 1
|
||||
}
|
||||
|
||||
start_service() {
|
||||
# --- STEP 1: process fronthaul APs with mld_id ---
|
||||
mld_ids=$(uci show mapcontroller | grep "^mapcontroller.@ap\[" | cut -d'=' -f1 | while read -r ap; do
|
||||
[ "$(uci -q get "$ap.type")" = "fronthaul" ] || continue
|
||||
uci -q get "$ap.mld_id"
|
||||
done | sort -u | grep -v '^$')
|
||||
|
||||
for mld_id in $mld_ids; do
|
||||
ap_list=""
|
||||
ssid_ref=""
|
||||
key_ref=""
|
||||
ssid_mismatch=0
|
||||
|
||||
# collect all fronthaul APs with this mld_id
|
||||
for ap in $(uci show mapcontroller | grep "^mapcontroller.@ap\[" | cut -d'=' -f1); do
|
||||
[ "$(uci -q get "$ap.type")" = "fronthaul" ] || continue
|
||||
cur_id=$(uci -q get "$ap.mld_id")
|
||||
[ "$cur_id" = "$mld_id" ] || continue
|
||||
|
||||
cur_ssid=$(uci -q get "$ap.ssid")
|
||||
cur_key=$(uci -q get "$ap.key")
|
||||
ap_list="$ap_list $ap"
|
||||
|
||||
if [ -z "$ssid_ref" ]; then
|
||||
ssid_ref="$cur_ssid"
|
||||
key_ref="$cur_key"
|
||||
elif [ "$cur_ssid" != "$ssid_ref" ]; then
|
||||
ssid_mismatch=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$ssid_mismatch" -eq 1 ]; then
|
||||
for ap in $ap_list; do
|
||||
logger -t mldsync "Removing mld_id from $ap due to SSID mismatch"
|
||||
uci -q delete "$ap.mld_id"
|
||||
done
|
||||
else
|
||||
for mld in $(uci show mapcontroller | grep "^mapcontroller.@mld\[" | cut -d'=' -f1); do
|
||||
[ "$(uci -q get "$mld.id")" = "$mld_id" ] || continue
|
||||
logger -t mldsync "Updating $mld with ssid=$ssid_ref and key=$key_ref"
|
||||
uci -q set "$mld.ssid=$ssid_ref"
|
||||
uci -q set "$mld.key=$key_ref"
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
# --- STEP 2: handle fronthaul APs with no mld_id but same SSID ---
|
||||
for ssid in $(uci show mapcontroller | grep "^mapcontroller.@ap\[" | cut -d'=' -f1 | while read -r ap; do
|
||||
[ "$(uci -q get "$ap.type")" = "fronthaul" ] || continue
|
||||
[ -z "$(uci -q get "$ap.mld_id")" ] || continue
|
||||
uci -q get "$ap.ssid"
|
||||
done | sort | uniq); do
|
||||
ap_group=""
|
||||
key_ref=""
|
||||
count=0
|
||||
|
||||
for ap in $(uci show mapcontroller | grep "^mapcontroller.@ap\[" | cut -d'=' -f1); do
|
||||
[ "$(uci -q get "$ap.type")" = "fronthaul" ] || continue
|
||||
[ "$(uci -q get "$ap.ssid")" = "$ssid" ] || continue
|
||||
[ -z "$(uci -q get "$ap.mld_id")" ] || continue
|
||||
ap_group="$ap_group $ap"
|
||||
key_ref=$(uci -q get "$ap.key")
|
||||
count=$((count + 1))
|
||||
done
|
||||
|
||||
[ "$count" -lt 2 ] && continue
|
||||
|
||||
# Find first available MLD ID
|
||||
available_mld_id=$(find_available_mld_id)
|
||||
if [ -z "$available_mld_id" ]; then
|
||||
logger -t mldsync "Warning: No available MLD ID found for SSID group: $ssid"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Assign the available MLD ID to all APs in the group
|
||||
for ap in $ap_group; do
|
||||
logger -t mldsync "Assigning mld_id=$available_mld_id to $ap (ssid=$ssid)"
|
||||
uci -q set "$ap.mld_id=$available_mld_id"
|
||||
done
|
||||
|
||||
# Update the corresponding MLD section
|
||||
for mld in $(uci show mapcontroller | grep "^mapcontroller.@mld\[" | cut -d'=' -f1); do
|
||||
[ "$(uci -q get "$mld.id")" = "$available_mld_id" ] || continue
|
||||
logger -t mldsync "Updating $mld with ssid=$ssid and key=$key_ref (from unassigned group)"
|
||||
uci -q set "$mld.ssid=$ssid"
|
||||
uci -q set "$mld.key=$key_ref"
|
||||
done
|
||||
done
|
||||
|
||||
uci -q commit mapcontroller
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "mapcontroller"
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue