From aa0609d1439fcc1440a5ff573cacfd6b7d079203 Mon Sep 17 00:00:00 2001 From: Lazox12 <65539565+Lazox12@users.noreply.github.com> Date: Sun, 19 Apr 2026 20:10:36 +0200 Subject: [PATCH] fix: auto restart of KIAUH after update (#781) * fixed auto update * fixed the restarting logic * testing * removed test * fix: colored output and remove subshell usage in kiauh_update_dialog --------- Co-authored-by: dw-0 --- kiauh.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/kiauh.sh b/kiauh.sh index dda2366..90a8399 100755 --- a/kiauh.sh +++ b/kiauh.sh @@ -15,18 +15,30 @@ clear -x # make sure we have the correct permissions while running the script umask 022 +# gets the path where this script is located +KIAUH_SRCDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) + +# colors +white="\033[37m" +cyan="\033[96m" +red="\033[91m" +yellow="\033[93m" +green="\033[92m" + #===================================================# #=================== UPDATE KIAUH ==================# #===================================================# function update_kiauh() { - status_msg "Updating KIAUH ..." + echo "Updating KIAUH ..." cd "${KIAUH_SRCDIR}" git reset --hard && git pull - ok_msg "Update complete! Please restart KIAUH." - exit 0 + echo "Update complete! Restarting..." + sleep 1 + exec "$0" "$@" # restarts the script + } #===================================================# @@ -65,16 +77,18 @@ function kiauh_update_dialog() { echo -e "\-------------------------------------------------------/" local yn - read -p "${cyan}###### Do you want to update now? (Y/n):${white} " yn + echo -ne "${cyan}###### Do you want to update now? (Y/n):${white} " + read yn while true; do case "${yn}" in Y|y|Yes|yes|"") - do_action "update_kiauh" + update_kiauh break;; N|n|No|no) break;; *) - deny_action "kiauh_update_dialog";; + echo -e "${red}Invalid input. Please try again.${white}" + kiauh_update_dialog;; esac done }