Update menu.sh

This commit is contained in:
MacRimi 2025-01-12 15:56:08 +01:00 committed by GitHub
parent 536542ea8d
commit 84ed46b421
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

82
menu.sh
View File

@ -14,22 +14,6 @@ msg_info() { echo -e " ${YW}[INFO] $1${CL}"; }
msg_ok() { echo -e " ${GN}[OK] $1${CL}"; }
msg_error() { echo -e " ${RD}[ERROR] $1${CL}"; }
# Detectar si se está ejecutando en la consola física de Proxmox
is_physical_console() {
if [ "$(tty)" = "/dev/tty1" ] || [ "$(tty)" = "/dev/tty2" ] || [ "$(tty)" = "/dev/tty3" ]; then
return 0 # Es consola física
else
return 1 # No es consola física
fi
}
# Determinar si se debe usar whiptail
if is_physical_console; then
USE_WHIPTAIL=false
else
USE_WHIPTAIL=true
fi
# Crear directorios necesarios
mkdir -p "$LANG_DIR"
@ -126,21 +110,10 @@ check_updates() {
if [ "$LOCAL_VERSION" != "$REMOTE_VERSION" ]; then
msg_info "$UPDATE_CHECKING"
if [ "$(printf '%s\n' "$LOCAL_VERSION" "$REMOTE_VERSION" | sort -V | tail -n1)" = "$REMOTE_VERSION" ]; then
if $USE_WHIPTAIL; then
if whiptail --title "$UPDATE_TITLE" --yesno "$UPDATE_PROMPT" 10 60; then
perform_update
else
msg_info "$UPDATE_POSTPONED"
fi
if whiptail --title "$UPDATE_TITLE" --yesno "$UPDATE_PROMPT" 10 60; then
perform_update
else
echo -e "${YW}$UPDATE_TITLE${CL}"
echo "$UPDATE_PROMPT"
read -p "¿Desea actualizar? (s/N): " response
if [[ $response =~ ^[Ss]$ ]]; then
perform_update
else
msg_info "$UPDATE_POSTPONED"
fi
msg_info "$UPDATE_POSTPONED"
fi
else
msg_info "$UPDATE_CURRENT"
@ -202,22 +175,11 @@ show_config_menu() {
# Mostrar menú principal
show_menu() {
while true; do
if $USE_WHIPTAIL; then
OPTION=$(whiptail --title "$MAIN_MENU_TITLE" --menu "$SELECT_OPTION" 15 60 4 \
"1" "$OPTION_1" \
"2" "$OPTION_2" \
"3" "$OPTION_3" \
"4" "$EXIT_MENU" 3>&1 1>&2 2>&3)
else
clear
echo -e "${YW}=== ${MAIN_MENU_TITLE} ===${CL}"
echo "1) $OPTION_1"
echo "2) $OPTION_2"
echo "3) $OPTION_3"
echo "q) $EXIT_MENU"
echo
read -p "$SELECT_OPTION " OPTION
fi
OPTION=$(whiptail --title "$MAIN_MENU_TITLE" --menu "$SELECT_OPTION" 15 60 4 \
"1" "$OPTION_1" \
"2" "$OPTION_2" \
"3" "$OPTION_3" \
"4" "$EXIT_MENU" 3>&1 1>&2 2>&3)
case $OPTION in
1)
@ -227,9 +189,6 @@ show_menu() {
else
msg_error "$SCRIPT_ERROR"
fi
if ! $USE_WHIPTAIL; then
read -p "$PRESS_ENTER"
fi
;;
2)
msg_info "$NETWORK_REPAIR_RUNNING"
@ -238,39 +197,22 @@ show_menu() {
else
msg_error "$NETWORK_REPAIR_ERROR"
fi
if ! $USE_WHIPTAIL; then
read -p "$PRESS_ENTER"
fi
;;
3)
show_config_menu
;;
4)
if $USE_WHIPTAIL; then
msg_ok "$EXIT_MESSAGE"
exit 0
fi
;;
q|Q)
if ! $USE_WHIPTAIL; then
msg_ok "$EXIT_MESSAGE"
exit 0
fi
msg_ok "$EXIT_MESSAGE"
exit 0
;;
*)
if $USE_WHIPTAIL; then
msg_ok "$EXIT_MESSAGE"
exit 0
else
msg_error "$INVALID_OPTION"
sleep 2
fi
msg_error "$INVALID_OPTION"
sleep 2
;;
esac
done
}
# Verificar dependencias
if ! command -v whiptail &> /dev/null; then
msg_info "$DEPS_INSTALLING"