-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
realtek-poe: build default config from board.json #25551
Open
Hurricos
wants to merge
1
commit into
openwrt:master
Choose a base branch
from
Hurricos:realtek-poe-add_config_to_packages
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+44
−1
Open
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
[ -e /etc/config/poe ] && exit 0 | ||
|
||
. /lib/functions.sh | ||
. /usr/share/libubox/jshn.sh | ||
|
||
CFG=/etc/board.json | ||
|
||
json_init | ||
json_load_file "${CFG}" | ||
|
||
json_is_a poe object || exit 0 | ||
|
||
umask 055 | ||
touch /etc/config/poe | ||
|
||
json_select poe | ||
json_get_vars budget | ||
|
||
uci add poe global | ||
uci set poe.@global[-1].budget="$budget" | ||
|
||
if json_is_a ports array; then | ||
json_get_values ports ports | ||
id='1' | ||
|
||
for port in $ports; do | ||
uci -q batch <<-EOF | ||
add poe port | ||
set poe.@port[-1].name='$port' | ||
set poe.@port[-1].id='$id' | ||
set poe.@port[-1].enable='1' | ||
EOF | ||
let id=id+1 | ||
done | ||
fi | ||
json_select .. | ||
|
||
uci commit | ||
|
||
exit 0 |
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.
The poe-common package also added a section to mark the config file as such. I don't quite remember what this means in terms of behaviour on upgrades etc, and I can't really find much documentation either.
From the opkg code, I think this results in detecting that the file exists and has been "modified" (created), thus doing The Right Thing (creating backup etc.) on package upgrades. I think the old package would just blindly replace the edited poe config file on upgrades. The uci-defaults script would do the same though, and won't touch the file if it already exists.
Hopefully this also means the config file is put in the config backup automatically on system upgrades, but you may have to check this.