mirror of
https://github.com/linuxboot/heads.git
synced 2025-04-07 19:34:26 +00:00
functions: Add toggle_config function for use in config GUI
toggle_config() toggles the value of a config. Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
This commit is contained in:
parent
39c655ae1d
commit
468643ee82
@ -314,6 +314,22 @@ replace_config() {
|
||||
rm -f ${CONFIG_FILE}.tmp
|
||||
}
|
||||
|
||||
invert_yn() {
|
||||
if [ "$1" = "y" ]; then
|
||||
echo "n"
|
||||
else
|
||||
echo "y"
|
||||
fi
|
||||
}
|
||||
|
||||
toggle_config() {
|
||||
CONFIG_FILE="$1"
|
||||
CONFIG_OPTION="$2"
|
||||
|
||||
NEW_SETTING="$(invert_yn "$(load_config_value "$CONFIG_OPTION")")"
|
||||
set_config "$CONFIG_FILE" "$CONFIG_SETTING" "$NEW_SETTING"
|
||||
}
|
||||
|
||||
# Set a config variable to a given value - replace it if it exists, or add it.
|
||||
# If added, the variable will be exported.
|
||||
set_config() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user