fix(desudo): don't run init.sh install-mode detect/write when sourced
start.sh sources init.sh for its function defs at runtime (Model A). The top-level install-mode auto-detect + initUpdateConfigOption write ran on every source, rewriting CFG_INSTALL_MODE via 'sudo sed' on the manager-owned config — denied under the scoped sudoers (the last per-command 'a password is required'), and spurious '"Auto-detected ..."' noise. Gate both on BASH_SOURCE==$0 (executed directly only); also drop the needless sudo from initUpdateConfigOption (config is manager-owned). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
This commit is contained in:
parent
6431e7abbe
commit
ac163e3808
13
init.sh
13
init.sh
@ -169,8 +169,11 @@ if [ "$init_local_install" = true ]; then
|
|||||||
param7="local"
|
param7="local"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Auto-detect installation mode based on provided parameters
|
# Auto-detect installation mode based on provided parameters. Only when init.sh
|
||||||
if [[ -z "$param7" ]]; then
|
# 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
|
# A reinstall that doesn't re-pass the git args must not silently
|
||||||
# downgrade an existing git install to local (that disables the updater
|
# downgrade an existing git install to local (that disables the updater
|
||||||
# and blanks the saved creds). Honor a git URL already saved from a
|
# 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")
|
local comment_part=$(echo "$original_line" | sed -n "s|^$config_option=[^#]*\(#.*\)|\1|p")
|
||||||
|
|
||||||
if [[ -n "$comment_part" ]]; then
|
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
|
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
|
fi
|
||||||
source "$config_file"
|
source "$config_file"
|
||||||
return 0
|
return 0
|
||||||
@ -223,7 +226,7 @@ initUpdateConfigOption() {
|
|||||||
return 1
|
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"
|
initUpdateConfigOption "CFG_INSTALL_MODE" "$param7"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user