From d954b8e313f850cfd33145f6ccacf242232a10e6 Mon Sep 17 00:00:00 2001 From: Tomi Eckert Date: Tue, 9 Sep 2025 16:32:40 +0200 Subject: [PATCH] update installer --- install.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 8b1d20f..c6025cf 100644 --- a/install.sh +++ b/install.sh @@ -45,18 +45,53 @@ select choice in "${options[@]}"; do # Loop through each URL in the list and download the file for url in $urls_to_download; do filename=$(basename "${url}") - echo " -> Downloading '${filename}'..." + # If it's a .conf file AND it already exists, ask to overwrite. + if [[ "${filename}" == *.conf && -f "${filename}" ]]; then + echo " -> Found existing config file: '${filename}'." + # Create a temporary file to download the new version for comparison + tmp_file=$(mktemp) - # Use curl to download the file - if curl -fsSL -o "${filename}" "${url}"; then - echo " ✅ Successfully downloaded '${filename}'." - # If the downloaded file is a shell script, make it executable - if [[ "${filename}" == *.sh ]]; then - chmod +x "${filename}" - echo " 🤖 Made '${filename}' executable." + # Download the new version silently to the temp file + if curl -fsSL -o "${tmp_file}" "${url}"; then + echo " 🔎 Comparing versions..." + echo "-------------------- DIFF START --------------------" + # Show a colorized diff if 'colordiff' is available, otherwise use regular 'diff' + if command -v colordiff &> /dev/null; then + colordiff -u "${filename}" "${tmp_file}" + else + diff -u "${filename}" "${tmp_file}" + fi + echo "--------------------- DIFF END ---------------------" + + # Ask the user for confirmation before overwriting + read -p "Do you want to overwrite '${filename}'? (y/N) " -n 1 -r REPLY + echo # Move to a new line for cleaner output + + if [[ $REPLY =~ ^[Yy]$ ]]; then + mv "${tmp_file}" "${filename}" + echo " ✅ Updated '${filename}'." + else + rm "${tmp_file}" + echo " 🤷 Kept existing version of '${filename}'." + fi + else + echo " ❌ Error: Failed to download new version of '${filename}' for comparison." + # Clean up the temp file on failure + rm -f "${tmp_file}" fi else - echo " ❌ Error: Failed to download '${filename}'." + # Original download logic for all other files (or new .conf files) + echo " -> Downloading '${filename}'..." + if curl -fsSL -o "${filename}" "${url}"; then + echo " ✅ Successfully downloaded '${filename}'." + # If the downloaded file is a shell script, make it executable + if [[ "${filename}" == *.sh ]]; then + chmod +x "${filename}" + echo " 🤖 Made '${filename}' executable." + fi + else + echo " ❌ Error: Failed to download '${filename}'." + fi fi done echo