Skip to content

Commit

Permalink
fix mt7622 setup-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
FFAC committed Feb 1, 2025
1 parent 971b604 commit 21a20b0
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions patches/mt7622-setup-mode-3438.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
From 217b18c13ef34a51d49dfaa3832f0312e49de90b Mon Sep 17 00:00:00 2001
From: Florian Maurer <[email protected]>
Date: Sat, 1 Feb 2025 11:45:26 +0100
Subject: [PATCH] gluon-setup-mode: rename phys before starting setup mode

Signed-off-by: Florian Maurer <[email protected]>
---
.../lib/gluon/setup-mode/rc.d/S20network | 2 ++
.../luasrc/usr/lib/lua/gluon/setup-mode.lua | 29 +++++++++++++++++++
2 files changed, 31 insertions(+)

diff --git a/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network b/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network
index 9721558299..586c8be2b7 100755
--- a/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network
+++ b/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network
@@ -48,6 +48,8 @@ start_service() {
init_switch
iw reg set "$(lua -e 'print(require("gluon.site").regdom())')"

+ /usr/bin/lua -e 'require("gluon.setup-mode").rename_phys()'
+
procd_open_instance
procd_set_param command /sbin/netifd -c /var/gluon/setup-mode/config
procd_set_param respawn
diff --git a/package/gluon-setup-mode/luasrc/usr/lib/lua/gluon/setup-mode.lua b/package/gluon-setup-mode/luasrc/usr/lib/lua/gluon/setup-mode.lua
index 3b107bf97c..b65672279d 100644
--- a/package/gluon-setup-mode/luasrc/usr/lib/lua/gluon/setup-mode.lua
+++ b/package/gluon-setup-mode/luasrc/usr/lib/lua/gluon/setup-mode.lua
@@ -1,4 +1,5 @@
local platform = require 'gluon.platform'
+local json = require 'jsonc'


local M = {}
@@ -11,4 +12,32 @@ function M.get_status_led()
end
end

+function M.rename_phys()
+ -- Load board data from JSON file
+ local board_data = json.load('/etc/board.json')
+ local wlan_data = board_data.wlan or {}
+
+ -- Iterate over all entries in wlan_data
+ for phyname, data in pairs(wlan_data) do
+ local path = data.path
+ if path then
+ -- Get the phyname using iwinfo
+ -- lua iwinfo does return nil by path instead
+ -- local other_phyname = iwinfo.nl80211.phyname('path=' .. path)
+
+ local f = io.popen("iwinfo nl80211 phyname path=" .. path)
+ local other_phyname = f:read("*a")
+ f:close()
+
+ -- Check if the retrieved phyname doesn't match the key
+ if other_phyname ~= "" and other_phyname ~= phyname then
+ -- Execute the command
+ os.execute(string.format("iw %s set name %s", other_phyname, phyname))
+
+ print(string.format("Renamed phy %s to %s", other_phyname, phyname))
+ end
+ end
+ end
+end
+
return M

0 comments on commit 21a20b0

Please sign in to comment.