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,34 +690,50 @@ EOF
systemctl start proxmox-telegram.service systemctl start proxmox-telegram.service
} }
# Menú principal # Menú principal
main_menu() { 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 while true; do
OPTION=$(eval whiptail --title "\"\$(translate \"Configuración de Notificaciones de Proxmox\")\"" \ # Preparar las opciones del menú
--menu "\"\$(translate \"Elige una opción:\")\"" 20 70 10 \ local menu_options=(
"1" "\"\$(translate \"Configurar Telegram\")\"" \ "1" "$(translate "Configurar Telegram")"
"2" "\"\$(translate \"Configurar Notificaciones\")\"" \ "2" "$(translate "Configurar Notificaciones")"
"3" "\"\$(translate \"Iniciar Servicio de Notificaciones\")\"" \ "3" "$(translate "Iniciar Servicio de Notificaciones")"
"4" "\"\$(translate \"Detener Servicio de Notificaciones\")\"" \ "4" "$(translate "Detener Servicio de Notificaciones")"
"5" "\"\$(translate \"Verificar Estado del Servicio\")\"" \ "5" "$(translate "Verificar Estado del Servicio")"
"7" "\"\$(translate \"Salir\")\"" \ )
$extra_option 3>&1 1>&2 2>&3)
# Añadir la opción de eliminar servicio solo si está instalado
if [[ $? -ne 0 ]]; then exit 0; fi 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 case "$OPTION" in
1) configure_telegram ;; 1) configure_telegram ;;
2) configure_notifications ;; 2) configure_notifications ;;
3) start_notification_service ;; 3) start_notification_service ;;
4) stop_notification_service ;; 4) stop_notification_service ;;
5) check_service_status ;; 5) check_service_status ;;
6) remove_systemd_service ;;
7) exit 0 ;; 7) exit 0 ;;
8) remove_systemd_service ;;
esac esac
done done
} }