-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regenerate network and system UCI configs on every reconfigure, switch to role-based interface configuration #2372
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c2a5f57
treewide: regenerate network and system configs on every reconfigure
neocturne 05c2951
gluon-core: sysconfig: avoid unnecessary writes
neocturne 4b8251c
gluon-core: initialize interfaces role configuration
neocturne c779d12
treewide: use interface roles as basis for network configuration
neocturne 316e96a
gluon-core, gluon-setup-mode: reset ifname sysconfigs on each update,…
neocturne 6dcee2e
gluon-web-network: update wired mesh settings for new role-based conf…
neocturne a671b50
gluon-core: preserve explicitly marked network and system sections
neocturne 210cacd
docs: update for role-based interface configuration
neocturne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
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
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
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
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
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,23 @@ | ||
#!/bin/sh | ||
|
||
NETWORK_CFG='/etc/config/network' | ||
NETWORK_SAVED="${NETWORK_CFG}_gluon-old" | ||
|
||
SYSTEM_CFG='/etc/config/system' | ||
SYSTEM_SAVED="${SYSTEM_CFG}_gluon-old" | ||
|
||
# Make sure everything is saved before we move away the config files | ||
uci commit | ||
|
||
# Save old configs (unless there is already a saved config, | ||
# which means that the previous upgrade was interrupted) | ||
if [ -s "$NETWORK_CFG" ] && ! [ -s "$NETWORK_SAVED" ]; then | ||
mv -f "$NETWORK_CFG" "$NETWORK_SAVED" | ||
fi | ||
if [ -s "$SYSTEM_CFG" ] && ! [ -s "$SYSTEM_SAVED" ]; then | ||
mv -f "$SYSTEM_CFG" "$SYSTEM_SAVED" | ||
fi | ||
|
||
# Generate a new network config | ||
rm -f /etc/board.json "$NETWORK_CFG" "$SYSTEM_CFG" | ||
config_generate | ||
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
31 changes: 31 additions & 0 deletions
31
package/gluon-core/luasrc/lib/gluon/upgrade/002-migrate-system
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,31 @@ | ||
#!/usr/bin/lua | ||
|
||
local uci = require('simple-uci').cursor() | ||
|
||
-- Migrate system section | ||
local system = uci:get_all('system_gluon-old', '@system[0]') | ||
if system then | ||
uci:tset('system', '@system[0]', system) | ||
end | ||
|
||
-- Migrate ntp section | ||
local ntp = uci:get_all('system_gluon-old', 'ntp') | ||
if ntp then | ||
uci:tset('system', 'ntp', ntp) | ||
end | ||
|
||
-- Migrate gpio_switch sections | ||
-- | ||
-- Only the value is copied from the old config, so updates to names and | ||
-- pins are preserved | ||
uci:foreach('system', 'gpio_switch', function(s) | ||
local name = s['.name'] | ||
local value = uci:get('system_gluon-old', name, 'value') | ||
if value then | ||
uci:set('system', name, 'value', value) | ||
end | ||
end) | ||
|
||
-- No other sections are migrated, so updated LED and RSSI configs can take effect | ||
|
||
uci:save('system') |
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
66 changes: 66 additions & 0 deletions
66
package/gluon-core/luasrc/lib/gluon/upgrade/021-interface-roles
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,66 @@ | ||
#!/usr/bin/lua | ||
|
||
local site = require 'gluon.site' | ||
local sysconfig = require 'gluon.sysconfig' | ||
local uci = require('simple-uci').cursor() | ||
local util = require 'gluon.util' | ||
|
||
-- Defaults from site.conf | ||
local roles = { | ||
lan = site.interfaces.lan.roles({'client'}), | ||
wan = site.interfaces.wan.roles({'uplink'}), | ||
} | ||
roles.single = site.interfaces.single.roles(roles.wan) | ||
|
||
-- Migration of Mesh-on-WAN/LAN setting from Gluon 2021.1 and older (to be removed in 2024) | ||
-- | ||
-- Wired meshing is enabled for single interfaces if either of the settings | ||
-- was previously enabled | ||
local mesh_lan_disabled = uci:get('network_gluon-old', 'mesh_lan', 'disabled') | ||
local mesh_wan_disabled = uci:get('network_gluon-old', 'mesh_wan', 'disabled') | ||
if mesh_wan_disabled == '0' then | ||
util.add_to_set(roles.wan, 'mesh') | ||
util.add_to_set(roles.single, 'mesh') | ||
elseif mesh_wan_disabled == '1' then | ||
util.remove_from_set(roles.wan, 'mesh') | ||
util.remove_from_set(roles.single, 'mesh') | ||
end | ||
if mesh_lan_disabled == '0' then | ||
util.add_to_set(roles.lan, 'mesh') | ||
util.add_to_set(roles.single, 'mesh') | ||
elseif mesh_lan_disabled == '1' then | ||
util.remove_from_set(roles.lan, 'mesh') | ||
util.remove_from_set(roles.single, 'mesh') | ||
end | ||
|
||
-- Migration of single to WAN/LAN or vice-versa (an interface was added or removed) | ||
-- We identify the WAN with the single interface in this case | ||
-- | ||
-- These settings only take effect when the section that is the target of the | ||
-- migration does not exist yet. | ||
if uci:get('gluon', 'iface_wan') then | ||
roles.single = uci:get_list('gluon', 'iface_wan', 'role') | ||
end | ||
if uci:get('gluon', 'iface_single') then | ||
roles.wan = uci:get_list('gluon', 'iface_single', 'role') | ||
end | ||
|
||
-- Non-existing interfaces are nil, so they will not be added to the table | ||
local interfaces = { | ||
lan = sysconfig.lan_ifname, | ||
wan = sysconfig.wan_ifname, | ||
single = sysconfig.single_ifname, | ||
} | ||
|
||
for iface in pairs(interfaces) do | ||
local section_name = 'iface_' .. iface | ||
if not uci:get('gluon', section_name) then | ||
uci:section('gluon', 'interface', section_name, { | ||
-- / prefix refers to sysconfig ifnames | ||
name = '/' .. iface, | ||
role = roles[iface], | ||
}) | ||
end | ||
end | ||
|
||
uci:save('gluon') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command doesn't seem to be silent...
Can we silence it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can redirect the output to
/dev/null
. I'm not sure if the script ever prints something interesting that might help with debugging though.