diff --git a/initrd/etc/functions b/initrd/etc/functions index 007c2c1f..f3cf513d 100755 --- a/initrd/etc/functions +++ b/initrd/etc/functions @@ -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() {