difos/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate
Shiji Yang 2f944ecd3e treewide: simplify kernel version number comparisons
Directly call the function "get_linux_version()" to get the integer
kernel version number.

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Link: https://github.com/openwrt/openwrt/pull/19172
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2025-07-14 22:30:20 +02:00

61 lines
1.3 KiB
Bash

#!/bin/sh
# This must run before 10-wifi-detect
[ "${ACTION}" = "add" ] || return
. /lib/functions.sh
. /lib/functions/system.sh
do_migrate_radio()
{
local cfg="$1" from="$2" to="$3"
config_get path "$cfg" path
[ "$path" = "$from" ] || return
uci set "wireless.${cfg}.path=${to}"
WIRELESS_CHANGED=true
logger -t wifi-migrate "Updated path of wireless.${cfg} from '${from}' to '${to}'"
}
check_path()
{
local config
config="$1"
config_get path "$config" path
to=${path/soc\//soc@0\/}
# Checks if kernel version is less than 6.6.0, if it is and the path is using the new format,
# then path should be migrated to the old format. This would allow users on platforms with two partitions,
# to test 6.1 and 6.6.
[ "$(get_linux_version)" -lt "606000" ] && to=${path/soc@0\//soc\/}
[ "$path" = "$to" ] || do_migrate_radio "$config" "$path" "$to"
}
migrate_radio()
{
config_load wireless
# Check if there is already a section with the target path: In this case, the system
# was already upgraded to a version without this migration script before; better bail out,
# as we can't be sure we don't break more than we fix.
config_foreach check_path wifi-device
}
WIRELESS_CHANGED=false
case "$(board_name)" in
*)
migrate_radio
;;
esac
$WIRELESS_CHANGED && uci commit wireless
exit 0