-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
FFAC
committed
Feb 1, 2025
1 parent
971b604
commit 21a20b0
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |