mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-13 18:44:29 +05:00
* fix: update all function (fixes #204) * fix: replace non-existing `print_unkown_cmd` function Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
@@ -292,20 +292,18 @@ function get_remote_fluidd_version() {
|
||||
}
|
||||
|
||||
function compare_fluidd_versions() {
|
||||
unset FLUIDD_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_fluidd_version)"
|
||||
remote_ver="$(get_remote_fluidd_version)"
|
||||
|
||||
if [[ ${local_ver} != "${remote_ver}" ]]; then
|
||||
if [[ ${local_ver} != "${remote_ver}" && ${local_ver} != "" ]]; then
|
||||
versions="${yellow}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
# add fluidd to the update all array for the update all function in the updater
|
||||
FLUIDD_UPDATE_AVAIL="true" && update_arr+=(update_fluidd)
|
||||
# add moonraker to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "fluidd"
|
||||
else
|
||||
versions="${green}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
FLUIDD_UPDATE_AVAIL="false"
|
||||
fi
|
||||
|
||||
echo "${versions}"
|
||||
|
||||
@@ -553,7 +553,6 @@ function get_remote_klipper_commit() {
|
||||
}
|
||||
|
||||
function compare_klipper_versions() {
|
||||
unset KLIPPER_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_klipper_commit)"
|
||||
remote_ver="$(get_remote_klipper_commit)"
|
||||
@@ -561,12 +560,11 @@ function compare_klipper_versions() {
|
||||
if [[ ${local_ver} != "${remote_ver}" ]]; then
|
||||
versions="${yellow}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
# add klipper to the update all array for the update all function in the updater
|
||||
KLIPPER_UPDATE_AVAIL="true" && update_arr+=(update_klipper)
|
||||
# add klipper to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "klipper"
|
||||
else
|
||||
versions="${green}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
KLIPPER_UPDATE_AVAIL="false"
|
||||
fi
|
||||
|
||||
echo "${versions}"
|
||||
|
||||
@@ -180,7 +180,6 @@ function get_remote_klipperscreen_commit() {
|
||||
}
|
||||
|
||||
function compare_klipperscreen_versions() {
|
||||
unset KLIPPERSCREEN_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_klipperscreen_commit)"
|
||||
remote_ver="$(get_remote_klipperscreen_commit)"
|
||||
@@ -188,12 +187,11 @@ function compare_klipperscreen_versions() {
|
||||
if [[ ${local_ver} != "${remote_ver}" ]]; then
|
||||
versions="${yellow}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
# add klipperscreen to the update all array for the update all function in the updater
|
||||
KLIPPERSCREEN_UPDATE_AVAIL="true" && update_arr+=(update_klipperscreen)
|
||||
# add moonraker to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "klipperscreen"
|
||||
else
|
||||
versions="${green}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
KLIPPERSCREEN_UPDATE_AVAIL="false"
|
||||
fi
|
||||
|
||||
echo "${versions}"
|
||||
|
||||
@@ -297,20 +297,18 @@ function get_remote_mainsail_version() {
|
||||
}
|
||||
|
||||
function compare_mainsail_versions() {
|
||||
unset MAINSAIL_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_mainsail_version)"
|
||||
remote_ver="$(get_remote_mainsail_version)"
|
||||
|
||||
if [[ ${local_ver} != "${remote_ver}" ]]; then
|
||||
if [[ ${local_ver} != "${remote_ver}" && ${local_ver} != "" ]]; then
|
||||
versions="${yellow}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
# add mainsail to the update all array for the update all function in the updater
|
||||
MAINSAIL_UPDATE_AVAIL="true" && update_arr+=(update_mainsail)
|
||||
# add moonraker to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "mainsail"
|
||||
else
|
||||
versions="${green}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
MAINSAIL_UPDATE_AVAIL="false"
|
||||
fi
|
||||
|
||||
echo "${versions}"
|
||||
|
||||
@@ -436,7 +436,6 @@ function get_remote_telegram_bot_commit() {
|
||||
}
|
||||
|
||||
function compare_telegram_bot_versions() {
|
||||
unset MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_telegram_bot_commit)"
|
||||
remote_ver="$(get_remote_telegram_bot_commit)"
|
||||
@@ -444,12 +443,11 @@ function compare_telegram_bot_versions() {
|
||||
if [[ ${local_ver} != "${remote_ver}" ]]; then
|
||||
versions="${yellow}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
# add moonraker-telegram-bot to the update all array for the update all function in the updater
|
||||
MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL="true" && update_arr+=(update_telegram_bot)
|
||||
# add moonraker to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "telegram_bot"
|
||||
else
|
||||
versions="${green}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL="false"
|
||||
fi
|
||||
|
||||
echo "${versions}"
|
||||
|
||||
@@ -557,7 +557,6 @@ function get_remote_moonraker_commit() {
|
||||
}
|
||||
|
||||
function compare_moonraker_versions() {
|
||||
unset MOONRAKER_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_moonraker_commit)"
|
||||
remote_ver="$(get_remote_moonraker_commit)"
|
||||
@@ -565,12 +564,11 @@ function compare_moonraker_versions() {
|
||||
if [[ ${local_ver} != "${remote_ver}" ]]; then
|
||||
versions="${yellow}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
# add moonraker to the update all array for the update all function in the updater
|
||||
MOONRAKER_UPDATE_AVAIL="true" && update_arr+=(update_moonraker)
|
||||
# add moonraker to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "moonraker"
|
||||
else
|
||||
versions="${green}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
MOONRAKER_UPDATE_AVAIL="false"
|
||||
fi
|
||||
|
||||
echo "${versions}"
|
||||
|
||||
@@ -260,8 +260,7 @@ function detect_conflicting_packages() {
|
||||
echo -e "###### > Skip"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
error_msg "Invalid command!";;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -109,7 +109,6 @@ function get_remote_prettygcode_commit() {
|
||||
}
|
||||
|
||||
function compare_prettygcode_versions() {
|
||||
unset PGC_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_prettygcode_commit)"
|
||||
remote_ver="$(get_remote_prettygcode_commit)"
|
||||
@@ -117,12 +116,11 @@ function compare_prettygcode_versions() {
|
||||
if [[ ${local_ver} != "${remote_ver}" ]]; then
|
||||
versions="${yellow}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
# add prettygcode to the update all array for the update all function in the updater
|
||||
PGC_UPDATE_AVAIL="true" && update_arr+=(update_pgc_for_klipper)
|
||||
# add moonraker to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "pgc_for_klipper"
|
||||
else
|
||||
versions="${green}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
PGC_UPDATE_AVAIL="false"
|
||||
fi
|
||||
|
||||
echo "${versions}"
|
||||
|
||||
@@ -37,7 +37,6 @@ function update_ui() {
|
||||
}
|
||||
|
||||
function update_menu() {
|
||||
unset update_arr
|
||||
do_action "" "update_ui"
|
||||
|
||||
local action
|
||||
@@ -74,6 +73,13 @@ function update_menu() {
|
||||
}
|
||||
|
||||
function update_all() {
|
||||
read_kiauh_ini "${FUNCNAME[0]}"
|
||||
|
||||
local update_arr
|
||||
local app_update_state="${application_updates_available}"
|
||||
|
||||
IFS=', ' read -r -a update_arr <<< "${app_update_state}"
|
||||
|
||||
while true; do
|
||||
if (( ${#update_arr[@]} == 0 )); then
|
||||
print_confirm "Everything is already up-to-date!"
|
||||
@@ -83,39 +89,39 @@ function update_all() {
|
||||
echo
|
||||
top_border
|
||||
echo -e "| The following installations will be updated: |"
|
||||
if [[ "${KLIPPER_UPDATE_AVAIL}" = "true" ]]; then
|
||||
|
||||
[[ "${update_arr[*]}" =~ "klipper" ]] && \
|
||||
echo -e "| ${cyan}● Klipper${white} |"
|
||||
fi
|
||||
if [[ "${MOONRAKER_UPDATE_AVAIL}" = "true" ]]; then
|
||||
|
||||
[[ "${update_arr[*]}" =~ "moonraker" ]] && \
|
||||
echo -e "| ${cyan}● Moonraker${white} |"
|
||||
fi
|
||||
if [[ "${MAINSAIL_UPDATE_AVAIL}" = "true" ]]; then
|
||||
|
||||
[[ "${update_arr[*]}" =~ "mainsail" ]] && \
|
||||
echo -e "| ${cyan}● Mainsail${white} |"
|
||||
fi
|
||||
if [[ "${FLUIDD_UPDATE_AVAIL}" = "true" ]]; then
|
||||
|
||||
[[ "${update_arr[*]}" =~ "fluidd" ]] && \
|
||||
echo -e "| ${cyan}● Fluidd${white} |"
|
||||
fi
|
||||
if [[ "${KLIPPERSCREEN_UPDATE_AVAIL}" = "true" ]]; then
|
||||
|
||||
[[ "${update_arr[*]}" =~ "klipperscreen" ]] && \
|
||||
echo -e "| ${cyan}● KlipperScreen${white} |"
|
||||
fi
|
||||
if [[ "${PGC_UPDATE_AVAIL}" = "true" ]]; then
|
||||
|
||||
[[ "${update_arr[*]}" =~ "pgc_for_klipper" ]] && \
|
||||
echo -e "| ${cyan}● PrettyGCode for Klipper${white} |"
|
||||
fi
|
||||
if [[ "${MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL}" = "true" ]]; then
|
||||
|
||||
[[ "${update_arr[*]}" =~ "telegram_bot" ]] && \
|
||||
echo -e "| ${cyan}● MoonrakerTelegramBot${white} |"
|
||||
fi
|
||||
if [[ "${SYS_UPDATE_AVAIL}" = "true" ]]; then
|
||||
|
||||
[[ "${update_arr[*]}" =~ "system" ]] && \
|
||||
echo -e "| ${cyan}● System${white} |"
|
||||
fi
|
||||
|
||||
bottom_border
|
||||
|
||||
local yn
|
||||
if (( ${#update_arr[@]} != 0 )); then
|
||||
read -p "${cyan}###### Do you want to proceed? (Y/n):${white} " yn
|
||||
case "${yn}" in
|
||||
Y|y|Yes|yes|"")
|
||||
for update in "${update_arr[@]}"
|
||||
do
|
||||
for app in "${update_arr[@]}"; do
|
||||
local update="update_${app}"
|
||||
#shellcheck disable=SC2250
|
||||
$update
|
||||
done
|
||||
@@ -123,9 +129,7 @@ function update_all() {
|
||||
N|n|No|no)
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
error_msg "Invalid command!";;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
@@ -141,6 +141,12 @@ function init_ini() {
|
||||
} >> "${INI_FILE}"
|
||||
fi
|
||||
|
||||
if ! grep -Eq "^application_updates_available=" "${INI_FILE}"; then
|
||||
echo -e "\napplication_updates_available=\c" >> "${INI_FILE}"
|
||||
else
|
||||
sed -i "/application_updates_available=/s/=.*/=/" "${INI_FILE}"
|
||||
fi
|
||||
|
||||
if ! grep -Eq "^backup_before_update=." "${INI_FILE}"; then
|
||||
echo -e "\nbackup_before_update=false\c" >> "${INI_FILE}"
|
||||
fi
|
||||
@@ -370,6 +376,18 @@ function set_custom_klipper_repo() {
|
||||
sed -i '$a'"custom_klipper_repo_branch=${branch}" "${INI_FILE}"
|
||||
}
|
||||
|
||||
function add_to_application_updates() {
|
||||
read_kiauh_ini "${FUNCNAME[0]}"
|
||||
|
||||
local application="${1}"
|
||||
local app_update_state="${application_updates_available}"
|
||||
|
||||
if ! grep -Eq "${application}" <<< "${app_update_state}"; then
|
||||
app_update_state="${app_update_state}${application},"
|
||||
sed -i "/application_updates_available=/s/=.*/=${app_update_state}/" "${INI_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
#================================================#
|
||||
#=============== HANDLE SERVICES ================#
|
||||
#================================================#
|
||||
@@ -474,11 +492,10 @@ function check_system_updates() {
|
||||
updates_avail=$(apt list --upgradeable 2>/dev/null | sed "1d")
|
||||
|
||||
if [[ -n ${updates_avail} ]]; then
|
||||
# add system updates to the update all array for the update all function in the updater
|
||||
SYS_UPDATE_AVAIL="true" && update_arr+=(update_system)
|
||||
info_msg="${yellow}System upgrade available!${white}"
|
||||
# add system to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "system"
|
||||
else
|
||||
SYS_UPDATE_AVAIL="false"
|
||||
info_msg="${green}System up to date! ${white}"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user