added overwrite protection
This commit is contained in:
@@ -102,8 +102,15 @@ install_unit() {
|
||||
local filename=$(basename "$template_url")
|
||||
local dest_path=/etc/systemd/system/"$filename"
|
||||
|
||||
log_info "Installing $filename..."
|
||||
if [ -e "$dest_path" ]; then
|
||||
get_input "CONFIRM_OVERWRITE" "Overwrite $dest_path? (y/n)" "y" "false"
|
||||
if [[ "${CONFIRM_OVERWRITE,,}" != "y" ]]; then
|
||||
echo "Skipping overwrite of ${dest_path}."
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
log_info "Installing $filename..."
|
||||
curl -sL $template_url | envsubst > "$dest_path"
|
||||
log_success "$filename installed to $dest_path"
|
||||
}
|
||||
@@ -138,7 +145,6 @@ else
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# 1. Collect Inputs
|
||||
# Example:
|
||||
get_input "HOST_NAME" "Enter Hostname" "$(hostname)" "false"
|
||||
|
||||
Reference in New Issue
Block a user