Update telegram-notifier.sh

This commit is contained in:
MacRimi 2025-03-26 19:45:22 +01:00
parent 69ed8ffe58
commit 71ad91f5f9

View File

@ -690,25 +690,41 @@ EOF
systemctl start proxmox-telegram.service
}
# Menú principal
main_menu() {
local extra_option=""
if [[ -f /etc/systemd/system/proxmox-telegram.service ]]; then
extra_option="8 \"\$(translate \"Eliminar Servicio de Notificaciones\")\""
fi
while true; do
OPTION=$(eval whiptail --title "\"\$(translate \"Configuración de Notificaciones de Proxmox\")\"" \
--menu "\"\$(translate \"Elige una opción:\")\"" 20 70 10 \
"1" "\"\$(translate \"Configurar Telegram\")\"" \
"2" "\"\$(translate \"Configurar Notificaciones\")\"" \
"3" "\"\$(translate \"Iniciar Servicio de Notificaciones\")\"" \
"4" "\"\$(translate \"Detener Servicio de Notificaciones\")\"" \
"5" "\"\$(translate \"Verificar Estado del Servicio\")\"" \
"7" "\"\$(translate \"Salir\")\"" \
$extra_option 3>&1 1>&2 2>&3)
# Preparar las opciones del menú
local menu_options=(
"1" "$(translate "Configurar Telegram")"
"2" "$(translate "Configurar Notificaciones")"
"3" "$(translate "Iniciar Servicio de Notificaciones")"
"4" "$(translate "Detener Servicio de Notificaciones")"
"5" "$(translate "Verificar Estado del Servicio")"
)
if [[ $? -ne 0 ]]; then exit 0; fi
# Añadir la opción de eliminar servicio solo si está instalado
if [[ -f /etc/systemd/system/proxmox-telegram.service ]]; then
menu_options+=(
"6" "$(translate "Eliminar Servicio de Notificaciones")"
)
fi
# Añadir siempre la opción de salir al final
menu_options+=(
"7" "$(translate "Salir")"
)
# Mostrar el menú con las opciones preparadas
OPTION=$(whiptail --title "$(translate "Configuración de Notificaciones de Proxmox")" \
--menu "$(translate "Elige una opción:")" 20 70 10 \
"${menu_options[@]}" \
3>&1 1>&2 2>&3)
if [[ $? -ne 0 ]]; then
exit 0
fi
case "$OPTION" in
1) configure_telegram ;;
@ -716,8 +732,8 @@ main_menu() {
3) start_notification_service ;;
4) stop_notification_service ;;
5) check_service_status ;;
6) remove_systemd_service ;;
7) exit 0 ;;
8) remove_systemd_service ;;
esac
done
}