refactor(kiauh.sh): improve kiauh update routine
Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
33
kiauh.sh
33
kiauh.sh
@@ -38,6 +38,37 @@ DMBUTYUGIN_REPO=https://github.com/dmbutyugin/klipper.git
|
|||||||
BRANCH_SCURVE_SMOOTHING=dmbutyugin/scurve-smoothing
|
BRANCH_SCURVE_SMOOTHING=dmbutyugin/scurve-smoothing
|
||||||
BRANCH_SCURVE_SHAPING=dmbutyugin/scurve-shaping
|
BRANCH_SCURVE_SHAPING=dmbutyugin/scurve-shaping
|
||||||
|
|
||||||
|
#===================================================#
|
||||||
|
#=================== UPDATE KIAUH ==================#
|
||||||
|
#===================================================#
|
||||||
|
|
||||||
|
function update_kiauh(){
|
||||||
|
status_msg "Updating KIAUH ..."
|
||||||
|
cd "${SRCDIR}/kiauh"
|
||||||
|
git reset --hard && git pull
|
||||||
|
ok_msg "Update complete! Please restart KIAUH."
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#===================================================#
|
||||||
|
#=================== KIAUH STATUS ==================#
|
||||||
|
#===================================================#
|
||||||
|
|
||||||
|
function kiauh_update_avail(){
|
||||||
|
[ ! -d "${SRCDIR}/kiauh/.git" ] && return
|
||||||
|
local origin head
|
||||||
|
cd "${SRCDIR}/kiauh"
|
||||||
|
### abort if not on master branch
|
||||||
|
! git branch -a | grep -q "\* master" && return
|
||||||
|
### compare commit hash
|
||||||
|
git fetch -q
|
||||||
|
origin=$(git rev-parse --short=8 origin/master)
|
||||||
|
head=$(git rev-parse --short=8 HEAD)
|
||||||
|
if [ "${origin}" != "${head}" ]; then
|
||||||
|
echo "true"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
### format some default message types
|
### format some default message types
|
||||||
select_msg() {
|
select_msg() {
|
||||||
echo -e "${white}>>>>>> $1"
|
echo -e "${white}>>>>>> $1"
|
||||||
@@ -113,5 +144,5 @@ clear_msg(){
|
|||||||
|
|
||||||
check_euid
|
check_euid
|
||||||
init_ini
|
init_ini
|
||||||
kiauh_status
|
kiauh_update_avail
|
||||||
main_menu
|
main_menu
|
||||||
|
|||||||
@@ -1,15 +1,3 @@
|
|||||||
kiauh_status(){
|
|
||||||
if [ -d "${SRCDIR}/kiauh/.git" ]; then
|
|
||||||
cd ${SRCDIR}/kiauh
|
|
||||||
if git branch -a | grep "* master" -q; then
|
|
||||||
git fetch -q
|
|
||||||
if [[ "$(git rev-parse --short=8 origin/master)" != "$(git rev-parse --short=8 HEAD)" ]]; then
|
|
||||||
KIAUH_UPDATE_AVAIL="true"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
check_system_updates(){
|
check_system_updates(){
|
||||||
SYS_UPDATE=$(apt list --upgradeable 2>/dev/null | sed "1d")
|
SYS_UPDATE=$(apt list --upgradeable 2>/dev/null | sed "1d")
|
||||||
if [ ! -z "$SYS_UPDATE" ]; then
|
if [ ! -z "$SYS_UPDATE" ]; then
|
||||||
|
|||||||
@@ -54,18 +54,6 @@ print_header(){
|
|||||||
bottom_border
|
bottom_border
|
||||||
}
|
}
|
||||||
|
|
||||||
kiauh_update_msg(){
|
|
||||||
top_border
|
|
||||||
echo -e "|${green} New KIAUH update available! ${default}| "
|
|
||||||
hr
|
|
||||||
echo -e "|${green} View Changelog: https://git.io/JnmlX ${default}| "
|
|
||||||
blank_line
|
|
||||||
echo -e "|${yellow} It is recommended to keep KIAUH up to date. Updates ${default}| "
|
|
||||||
echo -e "|${yellow} usually contain bugfixes, important changes or new ${default}| "
|
|
||||||
echo -e "|${yellow} features. Please consider updating! ${default}| "
|
|
||||||
bottom_border
|
|
||||||
}
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#******************************************************************************#
|
#******************************************************************************#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
@@ -12,13 +12,12 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
main_ui(){
|
main_ui(){
|
||||||
#[ $KIAUH_UPDATE_REMIND="true" ] && kiauh_update_reminder
|
|
||||||
top_border
|
top_border
|
||||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
||||||
hr
|
hr
|
||||||
echo -e "| 0) [Upload Log] | Klipper: $(get_klipper_status)|"
|
echo -e "| 0) [Upload Log] | Klipper: $(get_klipper_status)|"
|
||||||
echo -e "| | |"
|
echo -e "| | |"
|
||||||
echo -e "| 1) [Install] |--------------------------------|"
|
echo -e "| 1) [Install] | |"
|
||||||
echo -e "| 2) [Update] | Moonraker: $(get_moonraker_status)|"
|
echo -e "| 2) [Update] | Moonraker: $(get_moonraker_status)|"
|
||||||
echo -e "| 3) [Remove] | |"
|
echo -e "| 3) [Remove] | |"
|
||||||
echo -e "| 4) [Advanced] | Mainsail: $MAINSAIL_STATUS|"
|
echo -e "| 4) [Advanced] | Mainsail: $MAINSAIL_STATUS|"
|
||||||
@@ -26,21 +25,31 @@ main_ui(){
|
|||||||
echo -e "| | KlipperScreen: $KLIPPERSCREEN_STATUS|"
|
echo -e "| | KlipperScreen: $KLIPPERSCREEN_STATUS|"
|
||||||
echo -e "| 6) [Settings] | Telegram Bot: $MOONRAKER_TELEGRAM_BOT_STATUS|"
|
echo -e "| 6) [Settings] | Telegram Bot: $MOONRAKER_TELEGRAM_BOT_STATUS|"
|
||||||
echo -e "| | |"
|
echo -e "| | |"
|
||||||
echo -e "| ${cyan}${KIAUH_VER}${white}| Octoprint: $OCTOPRINT_STATUS|"
|
echo -e "| $(get_kiauh_version)| Octoprint: $OCTOPRINT_STATUS|"
|
||||||
quit_footer
|
quit_footer
|
||||||
}
|
}
|
||||||
|
|
||||||
print_kiauh_version(){
|
get_kiauh_version(){
|
||||||
cd ${SRCDIR}/kiauh
|
local version
|
||||||
KIAUH_VER=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
|
cd "${SRCDIR}/kiauh"
|
||||||
KIAUH_VER="$(printf "%-20s" "$KIAUH_VER")"
|
version="$(printf "%-20s" "$(git describe HEAD --always --tags | cut -d "-" -f 1,2)")"
|
||||||
|
echo "${cyan}${version}${white}"
|
||||||
}
|
}
|
||||||
|
|
||||||
kiauh_update_dialog(){
|
kiauh_update_dialog(){
|
||||||
kiauh_update_msg
|
[ ! "$(kiauh_update_avail)" == "true" ] && return
|
||||||
read -p "${cyan}Do you want to update now? (Y/n):${default} " yn
|
top_border
|
||||||
|
echo -e "|${green} New KIAUH update available! ${white}| "
|
||||||
|
hr
|
||||||
|
echo -e "|${green} View Changelog: https://git.io/JnmlX ${white}| "
|
||||||
|
blank_line
|
||||||
|
echo -e "|${yellow} It is recommended to keep KIAUH up to date. Updates ${white}| "
|
||||||
|
echo -e "|${yellow} usually contain bugfixes, important changes or new ${white}| "
|
||||||
|
echo -e "|${yellow} features. Please consider updating! ${white}| "
|
||||||
|
bottom_border
|
||||||
|
read -p "${cyan}Do you want to update now? (Y/n):${white} " 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"
|
do_action "update_kiauh"
|
||||||
break;;
|
break;;
|
||||||
@@ -53,24 +62,18 @@ kiauh_update_dialog(){
|
|||||||
|
|
||||||
main_menu(){
|
main_menu(){
|
||||||
print_header
|
print_header
|
||||||
#print KIAUH update msg if update available
|
#prompt for KIAUH update if update available
|
||||||
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
|
kiauh_update_dialog
|
||||||
kiauh_update_dialog
|
|
||||||
fi
|
|
||||||
#check install status
|
#check install status
|
||||||
print_kiauh_version
|
|
||||||
# klipper_status
|
|
||||||
# moonraker_status
|
|
||||||
fluidd_status
|
fluidd_status
|
||||||
mainsail_status
|
mainsail_status
|
||||||
octoprint_status
|
octoprint_status
|
||||||
klipperscreen_status
|
klipperscreen_status
|
||||||
MoonrakerTelegramBot_status
|
MoonrakerTelegramBot_status
|
||||||
# print_branch
|
|
||||||
print_msg && clear_msg
|
print_msg && clear_msg
|
||||||
main_ui
|
main_ui
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}Perform action:${default} " action; echo
|
read -p "${cyan}Perform action:${white} " action; echo
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
"start klipper") do_action_service "start" "klipper"; main_ui;;
|
"start klipper") do_action_service "start" "klipper"; main_ui;;
|
||||||
"stop klipper") do_action_service "stop" "klipper"; main_ui;;
|
"stop klipper") do_action_service "stop" "klipper"; main_ui;;
|
||||||
@@ -90,7 +93,7 @@ main_menu(){
|
|||||||
5) clear && backup_menu && break;;
|
5) clear && backup_menu && break;;
|
||||||
6) clear && settings_menu && break;;
|
6) clear && settings_menu && break;;
|
||||||
Q|q)
|
Q|q)
|
||||||
echo -e "${green}###### Happy printing! ######${default}"; echo
|
echo -e "${green}###### Happy printing! ######${white}"; echo
|
||||||
exit 0;;
|
exit 0;;
|
||||||
*)
|
*)
|
||||||
deny_action "main_ui";;
|
deny_action "main_ui";;
|
||||||
|
|||||||
@@ -1,14 +1,3 @@
|
|||||||
update_kiauh(){
|
|
||||||
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
|
|
||||||
status_msg "Updating KIAUH ..."
|
|
||||||
cd ${SRCDIR}/kiauh
|
|
||||||
### force reset kiauh before updating
|
|
||||||
git reset --hard
|
|
||||||
git pull && ok_msg "Update complete! Please restart KIAUH."
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
update_all(){
|
update_all(){
|
||||||
while true; do
|
while true; do
|
||||||
if [ "${#update_arr[@]}" = "0" ]; then
|
if [ "${#update_arr[@]}" = "0" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user