File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
files/lib/gluon/setup-mode/rc.d Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ start_service() {
4848 init_switch
4949 iw reg set " $( lua -e ' print(require("gluon.site").regdom())' ) "
5050
51+ /usr/bin/lua -e ' require("gluon.setup-mode").rename_phys()'
52+
5153 procd_open_instance
5254 procd_set_param command /sbin/netifd -c /var/gluon/setup-mode/config
5355 procd_set_param respawn
Original file line number Diff line number Diff line change 11local platform = require ' gluon.platform'
2+ local json = require ' jsonc'
23
34
45local M = {}
@@ -11,4 +12,32 @@ function M.get_status_led()
1112 end
1213end
1314
15+ function M .rename_phys ()
16+ -- Load board data from JSON file
17+ local board_data = json .load (' /etc/board.json' )
18+ local wlan_data = board_data .wlan or {}
19+
20+ -- Iterate over all entries in wlan_data
21+ for phyname , data in pairs (wlan_data ) do
22+ local path = data .path
23+ if path then
24+ -- Get the phyname using iwinfo
25+ -- lua iwinfo does return nil by path instead
26+ -- local other_phyname = iwinfo.nl80211.phyname('path=' .. path)
27+
28+ local f = io.popen (" iwinfo nl80211 phyname path=" .. path )
29+ local other_phyname = f :read (" *a" )
30+ f :close ()
31+
32+ -- Check if the retrieved phyname doesn't match the key
33+ if other_phyname ~= " " and other_phyname ~= phyname then
34+ -- Execute the command
35+ os.execute (string.format (" iw %s set name %s" , other_phyname , phyname ))
36+
37+ print (string.format (" Renamed phy %s to %s" , other_phyname , phyname ))
38+ end
39+ end
40+ end
41+ end
42+
1443return M
You can’t perform that action at this time.
0 commit comments