29-sep: [servicios] Migración watchers al VPS - Telegram Watcher y Shutdown Listener migrados al VPS - Recordatorios Msgbox eliminado - Scripts de instalación y documentación completa

This commit is contained in:
juanminsanz
2026-09-29 09:27:07 +02:00
parent b9800b6f25
commit bb50d468be
4 changed files with 329 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
#!/bin/bash
# configurar_servicios_vps.sh — Configurar servicios en el VPS
# Este script debe ejecutarse EN EL VPS como root
echo "================================"
echo "Configuración de servicios VPS"
echo "================================"
echo ""
# Solicitar credenciales
read -p "TELEGRAM_API_ID: " TELEGRAM_API_ID
read -p "TELEGRAM_API_HASH: " TELEGRAM_API_HASH
read -p "TELEGRAM_BOT_TOKEN: " TELEGRAM_BOT_TOKEN
read -p "SHUTDOWN_TOKEN [presiona Enter para usar el actual]: " SHUTDOWN_TOKEN
# Usar token actual si no se proporciona uno nuevo
if [ -z "$SHUTDOWN_TOKEN" ]; then
SHUTDOWN_TOKEN="H7iLGJixPp3J3pthCmnR2Ibq0tvERD5THyr_foAeN_8"
fi
echo ""
echo "Actualizando servicios con las credenciales..."
# Actualizar telegram-watcher.service
sed -i "s|Environment=TELEGRAM_API_ID=.*|Environment=TELEGRAM_API_ID=$TELEGRAM_API_ID|" /etc/systemd/system/telegram-watcher.service
sed -i "s|Environment=TELEGRAM_API_HASH=.*|Environment=TELEGRAM_API_HASH=$TELEGRAM_API_HASH|" /etc/systemd/system/telegram-watcher.service
sed -i "s|Environment=TELEGRAM_BOT_TOKEN=.*|Environment=TELEGRAM_BOT_TOKEN=$TELEGRAM_BOT_TOKEN|" /etc/systemd/system/telegram-watcher.service
# Actualizar shutdown-listener.service
sed -i "s|Environment=SHUTDOWN_TOKEN=.*|Environment=SHUTDOWN_TOKEN=$SHUTDOWN_TOKEN|" /etc/systemd/system/shutdown-listener.service
# Instalar dependencias Python
echo ""
echo "Instalando dependencias..."
pip3 install telethon flask python-dotenv
# Crear directorio de logs
mkdir -p /var/log/telegram_watcher
chmod 755 /var/log/telegram_watcher
# Dar permisos de ejecución
chmod +x /opt/telegram_watcher/telegram_watcher.py
chmod +x /opt/shutdown_listener/shutdown_listener.py
# Recargar systemd
echo ""
echo "Recargando systemd..."
systemctl daemon-reload
# Habilitar servicios
echo "Habilitando servicios..."
systemctl enable telegram-watcher.service
systemctl enable shutdown-listener.service
# Iniciar servicios
echo "Iniciando servicios..."
systemctl start telegram-watcher.service
systemctl start shutdown-listener.service
# Mostrar estado
echo ""
echo "================================"
echo "Estado de los servicios:"
echo "================================"
systemctl status telegram-watcher.service --no-pager
echo ""
systemctl status shutdown-listener.service --no-pager
echo ""
echo "================================"
echo "Configuración completada"
echo "================================"
echo ""
echo "Para ver logs en tiempo real:"
echo " journalctl -u telegram-watcher -f"
echo " journalctl -u shutdown-listener -f"
echo ""
echo "Log de mensajes de Telegram:"
echo " tail -f /var/log/telegram_watcher/mensajes.log"
echo ""