feat(install): Add optional install script execution for packages
This commit introduces the ability for packages to define an optional install script within the `packages.conf` file. The `install.sh` script will now parse this new field and execute the provided script after all associated package files have been downloaded. The `packages.conf` documentation has been updated to reflect the new format, including the optional fifth field for the install script.
This commit is contained in:
16
install.sh
16
install.sh
@@ -47,7 +47,8 @@ process_package() {
|
|||||||
display_name=$(echo "${config_value}" | cut -d'|' -f1)
|
display_name=$(echo "${config_value}" | cut -d'|' -f1)
|
||||||
remote_version=$(echo "${config_value}" | cut -d'|' -f2)
|
remote_version=$(echo "${config_value}" | cut -d'|' -f2)
|
||||||
description=$(echo "${config_value}" | cut -d'|' -f3)
|
description=$(echo "${config_value}" | cut -d'|' -f3)
|
||||||
urls_to_download=$(echo "${config_value}" | cut -d'|' -f4-)
|
urls_to_download=$(echo "${config_value}" | cut -d'|' -f4)
|
||||||
|
install_script=$(echo "${config_value}" | cut -d'|' -f5) # Optional install script
|
||||||
|
|
||||||
read -r -a urls_to_download_array <<< "$urls_to_download"
|
read -r -a urls_to_download_array <<< "$urls_to_download"
|
||||||
|
|
||||||
@@ -101,6 +102,16 @@ process_package() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ -n "${install_script}" ]]; then
|
||||||
|
echo "[⚙️] Running install script for '${choice_key}'..."
|
||||||
|
eval "${install_script}"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "[✅] Install script completed successfully."
|
||||||
|
else
|
||||||
|
echo "[❌] Install script failed with exit code $?."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
echo "[📦] Package processing complete for '${choice_key}'."
|
echo "[📦] Package processing complete for '${choice_key}'."
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +184,8 @@ for i in "${!ordered_keys[@]}"; do
|
|||||||
display_name=$(echo "${config_value}" | cut -d'|' -f1)
|
display_name=$(echo "${config_value}" | cut -d'|' -f1)
|
||||||
remote_version=$(echo "${config_value}" | cut -d'|' -f2)
|
remote_version=$(echo "${config_value}" | cut -d'|' -f2)
|
||||||
description=$(echo "${config_value}" | cut -d'|' -f3)
|
description=$(echo "${config_value}" | cut -d'|' -f3)
|
||||||
urls=$(echo "${config_value}" | cut -d'|' -f4-)
|
urls=$(echo "${config_value}" | cut -d'|' -f4)
|
||||||
|
# install_script=$(echo "${config_value}" | cut -d'|' -f5) # Not used for display in menu
|
||||||
read -r -a url_array <<< "$urls"
|
read -r -a url_array <<< "$urls"
|
||||||
main_script_filename=$(basename "${url_array[0]}")
|
main_script_filename=$(basename "${url_array[0]}")
|
||||||
local_version=$(get_local_version "${main_script_filename}")
|
local_version=$(get_local_version "${main_script_filename}")
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
# This file contains the configuration for the script downloader.
|
# This file contains the configuration for the script downloader.
|
||||||
# The `SCRIPT_PACKAGES` associative array maps a short package name
|
# The `SCRIPT_PACKAGES` associative array maps a short package name
|
||||||
# to a pipe-separated string with the following format:
|
# to a pipe-separated string with the following format:
|
||||||
# "<Display Name>|<Version>|<Description>|<Space-separated list of URLs>"
|
# "<Display Name>|<Version>|<Description>|<Space-separated list of URLs>|[Install Script (optional)]"
|
||||||
|
# The Install Script will be executed after all files for the package are downloaded.
|
||||||
|
|
||||||
declare -A SCRIPT_PACKAGES
|
declare -A SCRIPT_PACKAGES
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user