Skip to content

Commit 21a20b0

Browse files
author
FFAC
committed
fix mt7622 setup-mode
1 parent 971b604 commit 21a20b0

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

patches/mt7622-setup-mode-3438.patch

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
From 217b18c13ef34a51d49dfaa3832f0312e49de90b Mon Sep 17 00:00:00 2001
2+
From: Florian Maurer <[email protected]>
3+
Date: Sat, 1 Feb 2025 11:45:26 +0100
4+
Subject: [PATCH] gluon-setup-mode: rename phys before starting setup mode
5+
6+
Signed-off-by: Florian Maurer <[email protected]>
7+
---
8+
.../lib/gluon/setup-mode/rc.d/S20network | 2 ++
9+
.../luasrc/usr/lib/lua/gluon/setup-mode.lua | 29 +++++++++++++++++++
10+
2 files changed, 31 insertions(+)
11+
12+
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
13+
index 9721558299..586c8be2b7 100755
14+
--- a/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network
15+
+++ b/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network
16+
@@ -48,6 +48,8 @@ start_service() {
17+
init_switch
18+
iw reg set "$(lua -e 'print(require("gluon.site").regdom())')"
19+
20+
+ /usr/bin/lua -e 'require("gluon.setup-mode").rename_phys()'
21+
+
22+
procd_open_instance
23+
procd_set_param command /sbin/netifd -c /var/gluon/setup-mode/config
24+
procd_set_param respawn
25+
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
26+
index 3b107bf97c..b65672279d 100644
27+
--- a/package/gluon-setup-mode/luasrc/usr/lib/lua/gluon/setup-mode.lua
28+
+++ b/package/gluon-setup-mode/luasrc/usr/lib/lua/gluon/setup-mode.lua
29+
@@ -1,4 +1,5 @@
30+
local platform = require 'gluon.platform'
31+
+local json = require 'jsonc'
32+
33+
34+
local M = {}
35+
@@ -11,4 +12,32 @@ function M.get_status_led()
36+
end
37+
end
38+
39+
+function M.rename_phys()
40+
+ -- Load board data from JSON file
41+
+ local board_data = json.load('/etc/board.json')
42+
+ local wlan_data = board_data.wlan or {}
43+
+
44+
+ -- Iterate over all entries in wlan_data
45+
+ for phyname, data in pairs(wlan_data) do
46+
+ local path = data.path
47+
+ if path then
48+
+ -- Get the phyname using iwinfo
49+
+ -- lua iwinfo does return nil by path instead
50+
+ -- local other_phyname = iwinfo.nl80211.phyname('path=' .. path)
51+
+
52+
+ local f = io.popen("iwinfo nl80211 phyname path=" .. path)
53+
+ local other_phyname = f:read("*a")
54+
+ f:close()
55+
+
56+
+ -- Check if the retrieved phyname doesn't match the key
57+
+ if other_phyname ~= "" and other_phyname ~= phyname then
58+
+ -- Execute the command
59+
+ os.execute(string.format("iw %s set name %s", other_phyname, phyname))
60+
+
61+
+ print(string.format("Renamed phy %s to %s", other_phyname, phyname))
62+
+ end
63+
+ end
64+
+ end
65+
+end
66+
+
67+
return M

0 commit comments

Comments
 (0)