diff --git a/init.sh b/init.sh index e9bde21..10249b6 100755 --- a/init.sh +++ b/init.sh @@ -169,8 +169,11 @@ if [ "$init_local_install" = true ]; then param7="local" fi -# Auto-detect installation mode based on provided parameters -if [[ -z "$param7" ]]; then +# Auto-detect installation mode based on provided parameters. Only when init.sh +# is EXECUTED directly (install time) — start.sh sources init.sh for its function +# definitions at runtime (Model A, as the manager), and this block must not run +# then (it would print a spurious "Auto-detected ..." and rewrite the config). +if [[ "${BASH_SOURCE[0]}" == "$0" && -z "$param7" ]]; then # A reinstall that doesn't re-pass the git args must not silently # downgrade an existing git install to local (that disables the updater # and blanks the saved creds). Honor a git URL already saved from a @@ -208,9 +211,9 @@ initUpdateConfigOption() { local comment_part=$(echo "$original_line" | sed -n "s|^$config_option=[^#]*\(#.*\)|\1|p") if [[ -n "$comment_part" ]]; then - sudo sed -i "s|^$config_option=.*|$config_option=$escaped_value $comment_part|" "$config_file" + sed -i "s|^$config_option=.*|$config_option=$escaped_value $comment_part|" "$config_file" else - sudo sed -i "s|^$config_option=.*|$config_option=$escaped_value|" "$config_file" + sed -i "s|^$config_option=.*|$config_option=$escaped_value|" "$config_file" fi source "$config_file" return 0 @@ -223,7 +226,7 @@ initUpdateConfigOption() { return 1 } -if [[ -n "$param7" && -f "${configs_dir}general/general_install" ]]; then +if [[ "${BASH_SOURCE[0]}" == "$0" && -n "$param7" && -f "${configs_dir}general/general_install" ]]; then initUpdateConfigOption "CFG_INSTALL_MODE" "$param7" fi