-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
treewide: regenerate network and system configs on every reconfigure
- Loading branch information
Showing
15 changed files
with
100 additions
and
89 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
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,20 @@ | ||
#!/bin/sh | ||
|
||
NETWORK_CFG='/etc/config/network' | ||
NETWORK_SAVED="${NETWORK_CFG}_gluon-old" | ||
|
||
SYSTEM_CFG='/etc/config/system' | ||
SYSTEM_SAVED="${SYSTEM_CFG}_gluon-old" | ||
|
||
# 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 "$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
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