mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-06-28 12:16:53 +00:00
Update telegram-notifier.sh
This commit is contained in:
parent
0e5efbf619
commit
f4654f0046
@ -633,10 +633,15 @@ remove_systemd_service() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Función para instalar el servicio como un servicio systemd
|
# Función para instalar el servicio como un servicio systemd
|
||||||
install_systemd_service() {
|
install_systemd_service() {
|
||||||
SCRIPT_PATH=$(readlink -f "$0")
|
|
||||||
mkdir -p "$PID_DIR"
|
mkdir -p "$PID_DIR"
|
||||||
|
|
||||||
cat > /etc/systemd/system/proxmox-telegram.service <<EOF
|
cat > /etc/systemd/system/proxmox-telegram.service <<EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Proxmox Telegram Notification Service
|
Description=Proxmox Telegram Notification Service
|
||||||
@ -644,8 +649,8 @@ After=network.target pve-cluster.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=$SCRIPT_PATH start_silent
|
ExecStart=/bin/bash -c 'bash <(curl -fsSL https://raw.githubusercontent.com/MacRimi/ProxMenux/main/scripts/telegram-notifier.sh) start_silent'
|
||||||
ExecStop=$SCRIPT_PATH stop_silent
|
ExecStop=/bin/bash -c 'bash <(curl -fsSL https://raw.githubusercontent.com/MacRimi/ProxMenux/main/scripts/telegram-notifier.sh) stop_silent'
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
PIDFile=$PID_DIR/service.pid
|
PIDFile=$PID_DIR/service.pid
|
||||||
|
|
||||||
@ -653,49 +658,29 @@ PIDFile=$PID_DIR/service.pid
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reexec
|
||||||
systemctl enable proxmox-telegram.service
|
systemctl enable proxmox-telegram.service
|
||||||
systemctl start proxmox-telegram.service
|
systemctl start proxmox-telegram.service
|
||||||
}
|
}
|
||||||
|
|
||||||
# Funciones de ejemplo requeridas por systemd
|
|
||||||
start_silent() {
|
|
||||||
capture_journal_events > /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
|
# Menú principal
|
||||||
main_menu() {
|
main_menu() {
|
||||||
local extra_option=""
|
local extra_option=""
|
||||||
if [[ -f /etc/systemd/system/proxmox-telegram.service ]]; then
|
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
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
OPTION=$(whiptail --title "$(translate 'Configuración de Notificaciones de Proxmox')" \
|
OPTION=$(eval whiptail --title "\"\$(translate \"Configuración de Notificaciones de Proxmox\")\"" \
|
||||||
--menu "$(translate 'Elige una opción:')" 20 70 10 \
|
--menu "\"\$(translate \"Elige una opción:\")\"" 20 70 10 \
|
||||||
"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')" \
|
"7" "\"\$(translate \"Salir\")\"" \
|
||||||
$extra_option 3>&1 1>&2 2>&3)
|
$extra_option 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then exit 0; fi
|
if [[ $? -ne 0 ]]; then exit 0; fi
|
||||||
|
|
||||||
case "$OPTION" in
|
case "$OPTION" in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user