diff --git a/scripts/telegram-notifier.sh b/scripts/telegram-notifier.sh index 85e97f6..d3beecc 100644 --- a/scripts/telegram-notifier.sh +++ b/scripts/telegram-notifier.sh @@ -633,10 +633,15 @@ remove_systemd_service() { fi } + + + + + # Función para instalar el servicio como un servicio systemd install_systemd_service() { - SCRIPT_PATH=$(readlink -f "$0") mkdir -p "$PID_DIR" + cat > /etc/systemd/system/proxmox-telegram.service < /dev/null 2>&1 & echo $! > "$PID_DIR/journal.pid" - capture_direct_events > /dev/null 2>&1 & echo $! > "$PID_DIR/direct.pid" - echo $$ > "$PID_DIR/service.pid" -} - -stop_silent() { - kill $(cat "$PID_DIR/journal.pid" 2>/dev/null) 2>/dev/null - kill $(cat "$PID_DIR/direct.pid" 2>/dev/null) 2>/dev/null - kill $(cat "$PID_DIR/service.pid" 2>/dev/null) 2>/dev/null - rm -f "$PID_DIR"/*.pid -} - - - - - - # Menú principal main_menu() { local extra_option="" if [[ -f /etc/systemd/system/proxmox-telegram.service ]]; then - extra_option="8 \"$(translate \"Eliminar Servicio de Notificaciones\")\"" + extra_option="8 \"\$(translate \"Eliminar Servicio de Notificaciones\")\"" fi while true; do - OPTION=$(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')" \ + 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) - if [[ $? -ne 0 ]]; then exit 0; fi case "$OPTION" in