mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-13 10:34:28 +05:00
feat: KIAUH v4.0.0 (#191)
This commit is contained in:
@@ -1,89 +1,124 @@
|
||||
main_ui(){
|
||||
#[ $KIAUH_UPDATE_REMIND="true" ] && kiauh_update_reminder
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#=======================================================================#
|
||||
# Copyright (C) 2020 - 2022 Dominik Willner <th33xitus@gmail.com> #
|
||||
# #
|
||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||
# https://github.com/th33xitus/kiauh #
|
||||
# #
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||
#=======================================================================#
|
||||
|
||||
set -e
|
||||
|
||||
function main_ui() {
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
||||
hr
|
||||
echo -e "| 0) [Upload Log] | Klipper: $KLIPPER_STATUS|"
|
||||
echo -e "| | Branch: ${cyan}$PRINT_BRANCH${default}|"
|
||||
echo -e "| 1) [Install] | |"
|
||||
echo -e "| 2) [Update] | Moonraker: $MOONRAKER_STATUS|"
|
||||
echo -e "| 3) [Remove] | |"
|
||||
echo -e "| 4) [Advanced] | Mainsail: $MAINSAIL_STATUS|"
|
||||
echo -e "| 5) [Backup] | Fluidd: $FLUIDD_STATUS|"
|
||||
echo -e "| | KlipperScreen: $KLIPPERSCREEN_STATUS|"
|
||||
echo -e "| 6) [Settings] | Telegram Bot: $MOONRAKER_TELEGRAM_BOT_STATUS|"
|
||||
echo -e "| | |"
|
||||
echo -e "| | DWC2: $DWC2_STATUS|"
|
||||
echo -e "| ${cyan}$KIAUH_VER${default}| Octoprint: $OCTOPRINT_STATUS|"
|
||||
echo -e "| 0) [Log-Upload] | Klipper: $(print_status "klipper")|"
|
||||
echo -e "| | Repo: $(print_klipper_repo)|"
|
||||
echo -e "| 1) [Install] | |"
|
||||
echo -e "| 2) [Update] | Moonraker: $(print_status "moonraker")|"
|
||||
echo -e "| 3) [Remove] | |"
|
||||
echo -e "| 4) [Advanced] | Mainsail: $(print_status "mainsail")|"
|
||||
echo -e "| 5) [Backup] | Fluidd: $(print_status "fluidd")|"
|
||||
echo -e "| | KlipperScreen: $(print_status "klipperscreen")|"
|
||||
echo -e "| 6) [Settings] | Telegram Bot: $(print_status "telegram_bot")|"
|
||||
echo -e "| | |"
|
||||
echo -e "| $(print_kiauh_version)| Octoprint: $(print_status "octoprint")|"
|
||||
quit_footer
|
||||
}
|
||||
|
||||
print_kiauh_version(){
|
||||
cd ${SRCDIR}/kiauh
|
||||
KIAUH_VER=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
|
||||
KIAUH_VER="$(printf "%-20s" "$KIAUH_VER")"
|
||||
function get_kiauh_version() {
|
||||
local version
|
||||
cd "${KIAUH_SRCDIR}"
|
||||
version="$(git describe HEAD --always --tags | cut -d "-" -f 1,2)"
|
||||
echo "${version}"
|
||||
}
|
||||
|
||||
kiauh_update_dialog(){
|
||||
kiauh_update_msg
|
||||
read -p "${cyan}Do you want to update now? (Y/n):${default} " yn
|
||||
while true; do
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
do_action "update_kiauh"
|
||||
break;;
|
||||
N|n|No|no) break;;
|
||||
*)
|
||||
deny_action "kiauh_update_dialog";;
|
||||
esac
|
||||
done
|
||||
function print_kiauh_version() {
|
||||
local version
|
||||
version="$(printf "%-18s" "$(get_kiauh_version)")"
|
||||
echo "${cyan}${version}${white}"
|
||||
}
|
||||
|
||||
main_menu(){
|
||||
print_header
|
||||
#print KIAUH update msg if update available
|
||||
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
|
||||
kiauh_update_dialog
|
||||
fi
|
||||
#check install status
|
||||
print_kiauh_version
|
||||
klipper_status
|
||||
moonraker_status
|
||||
dwc2_status
|
||||
fluidd_status
|
||||
mainsail_status
|
||||
octoprint_status
|
||||
klipperscreen_status
|
||||
MoonrakerTelegramBot_status
|
||||
print_branch
|
||||
print_msg && clear_msg
|
||||
main_ui
|
||||
function print_status() {
|
||||
local status component="${1}"
|
||||
status=$(get_"${component}"_status)
|
||||
|
||||
if [[ ${status} == "Not installed!" ]]; then
|
||||
status="${red}${status}${white}"
|
||||
elif [[ ${status} == "Incomplete!" ]]; then
|
||||
status="${yellow}${status}${white}"
|
||||
else
|
||||
status="${green}${status}${white}"
|
||||
fi
|
||||
|
||||
printf "%-28s" "${status}"
|
||||
}
|
||||
|
||||
function print_klipper_repo() {
|
||||
read_kiauh_ini
|
||||
|
||||
local repo klipper_status
|
||||
klipper_status=$(get_klipper_status)
|
||||
repo=$(echo "${custom_klipper_repo}" | sed "s/https:\/\/github\.com\///" | sed "s/\.git$//")
|
||||
repo="${repo^^}"
|
||||
|
||||
if [[ ${klipper_status} == "Not installed!" ]]; then
|
||||
repo="${red}-${white}"
|
||||
elif [[ -n ${repo} && ${repo} != "KLIPPER3D/KLIPPER" ]]; then
|
||||
repo="${cyan}custom${white}"
|
||||
else
|
||||
repo="${cyan}Klipper3d/klipper${white}"
|
||||
fi
|
||||
|
||||
printf "%-28s" "${repo}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
function main_menu() {
|
||||
print_header && main_ui
|
||||
|
||||
local action
|
||||
while true; do
|
||||
read -p "${cyan}Perform action:${default} " action; echo
|
||||
case "$action" in
|
||||
read -p "${cyan}####### Perform action:${white} " action
|
||||
case "${action}" in
|
||||
"start klipper") do_action_service "start" "klipper"; main_ui;;
|
||||
"stop klipper") do_action_service "stop" "klipper"; main_ui;;
|
||||
"restart klipper") do_action_service "restart" "klipper"; main_ui;;
|
||||
"start moonraker") do_action_service "start" "moonraker"; main_ui;;
|
||||
"stop moonraker") do_action_service "stop" "moonraker"; main_ui;;
|
||||
"restart moonraker")do_action_service "restart" "moonraker"; main_ui;;
|
||||
"start dwc") do_action_service "start" "dwc"; main_ui;;
|
||||
"stop dwc") do_action_service "stop" "dwc"; main_ui;;
|
||||
"restart dwc") do_action_service "restart" "dwc"; main_ui;;
|
||||
"start octoprint") do_action_service "start" "octoprint"; main_ui;;
|
||||
"stop octoprint") do_action_service "stop" "octoprint"; main_ui;;
|
||||
"restart octoprint") do_action_service "restart" "octoprint"; main_ui;;
|
||||
update) do_action "update_kiauh" "main_ui";;
|
||||
0) do_action "upload_selection" "main_ui";;
|
||||
1) clear && install_menu && break;;
|
||||
2) clear && update_menu && break;;
|
||||
3) clear && remove_menu && break;;
|
||||
4) clear && advanced_menu && break;;
|
||||
5) clear && backup_menu && break;;
|
||||
6) clear && settings_menu && break;;
|
||||
0)clear && print_header
|
||||
upload_selection
|
||||
break;;
|
||||
1)clear && print_header
|
||||
install_menu
|
||||
break;;
|
||||
2) clear && print_header
|
||||
update_menu
|
||||
break;;
|
||||
3) clear && print_header
|
||||
remove_menu
|
||||
break;;
|
||||
4)clear && print_header
|
||||
advanced_menu
|
||||
break;;
|
||||
5)clear && print_header
|
||||
backup_menu
|
||||
break;;
|
||||
6)clear && print_header
|
||||
settings_menu
|
||||
break;;
|
||||
Q|q)
|
||||
echo -e "${green}###### Happy printing! ######${default}"; echo
|
||||
exit -1;;
|
||||
echo -e "${green}###### Happy printing! ######${white}"; echo
|
||||
exit 0;;
|
||||
*)
|
||||
deny_action "main_ui";;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user