mirror of
https://github.com/dw-0/kiauh.git
synced 2026-05-04 16:28:22 +05:00
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 <th33xitus@gmail.com>
This commit is contained in:
@@ -15,18 +15,30 @@ clear -x
|
|||||||
# make sure we have the correct permissions while running the script
|
# make sure we have the correct permissions while running the script
|
||||||
umask 022
|
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 ==================#
|
#=================== UPDATE KIAUH ==================#
|
||||||
#===================================================#
|
#===================================================#
|
||||||
|
|
||||||
function update_kiauh() {
|
function update_kiauh() {
|
||||||
status_msg "Updating KIAUH ..."
|
echo "Updating KIAUH ..."
|
||||||
|
|
||||||
cd "${KIAUH_SRCDIR}"
|
cd "${KIAUH_SRCDIR}"
|
||||||
git reset --hard && git pull
|
git reset --hard && git pull
|
||||||
|
|
||||||
ok_msg "Update complete! Please restart KIAUH."
|
echo "Update complete! Restarting..."
|
||||||
exit 0
|
sleep 1
|
||||||
|
exec "$0" "$@" # restarts the script
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#===================================================#
|
#===================================================#
|
||||||
@@ -65,16 +77,18 @@ function kiauh_update_dialog() {
|
|||||||
echo -e "\-------------------------------------------------------/"
|
echo -e "\-------------------------------------------------------/"
|
||||||
|
|
||||||
local yn
|
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
|
while true; do
|
||||||
case "${yn}" in
|
case "${yn}" in
|
||||||
Y|y|Yes|yes|"")
|
Y|y|Yes|yes|"")
|
||||||
do_action "update_kiauh"
|
update_kiauh
|
||||||
break;;
|
break;;
|
||||||
N|n|No|no)
|
N|n|No|no)
|
||||||
break;;
|
break;;
|
||||||
*)
|
*)
|
||||||
deny_action "kiauh_update_dialog";;
|
echo -e "${red}Invalid input. Please try again.${white}"
|
||||||
|
kiauh_update_dialog;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user