update installer
This commit is contained in:
53
install.sh
53
install.sh
@@ -45,18 +45,53 @@ select choice in "${options[@]}"; do
|
|||||||
# Loop through each URL in the list and download the file
|
# Loop through each URL in the list and download the file
|
||||||
for url in $urls_to_download; do
|
for url in $urls_to_download; do
|
||||||
filename=$(basename "${url}")
|
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
|
# Download the new version silently to the temp file
|
||||||
if curl -fsSL -o "${filename}" "${url}"; then
|
if curl -fsSL -o "${tmp_file}" "${url}"; then
|
||||||
echo " ✅ Successfully downloaded '${filename}'."
|
echo " 🔎 Comparing versions..."
|
||||||
# If the downloaded file is a shell script, make it executable
|
echo "-------------------- DIFF START --------------------"
|
||||||
if [[ "${filename}" == *.sh ]]; then
|
# Show a colorized diff if 'colordiff' is available, otherwise use regular 'diff'
|
||||||
chmod +x "${filename}"
|
if command -v colordiff &> /dev/null; then
|
||||||
echo " 🤖 Made '${filename}' executable."
|
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
|
fi
|
||||||
else
|
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
|
fi
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
|
|||||||
Reference in New Issue
Block a user