superguardado: reboot resiliente - comando reboot/servicios en bot + tunel autossh como servicio systemd + lecciones 32-35

This commit is contained in:
minguezsanzjuanjose
2026-08-02 23:38:46 +02:00
parent 312646f510
commit 4a53b3859f
2 changed files with 30 additions and 1 deletions

View File

@@ -162,8 +162,26 @@ def procesar(texto, chat_id):
"<b>alarma &lt;mensaje&gt;</b> — secuencia completa (sirena x3)\n"
"<b>youtube &lt;URL&gt;</b> — reproduce YouTube y apaga al terminar\n"
"<b>panorama</b> — fotos de las cámaras\n"
"<b>limpieza</b> — limpia procesos atascados de la Pi",
"<b>limpieza</b> — limpia procesos atascados de la Pi\n"
"<b>reboot</b> — reinicia la Pi (necesita confirmar con /confirmar-reboot)\n"
"<b>servicios</b> — estado de los servicios del sistema",
chat_id)
elif t in ("servicios", "/servicios"):
estado_svc = sh("systemctl is-active pi-bot tv-api autossh-tunel")
nombres = "pi-bot\ntv-api\nautossh-tunel"
activos = estado_svc.strip().splitlines()
lineas = []
for n, e in zip(["pi-bot", "tv-api", "autossh-tunel"], activos):
icono = "" if e == "active" else ""
lineas.append(f"{icono} {n}: {e}")
envio = "\n".join(lineas)
enviar(f"📦 Servicios:\n{envio}\n\n🔌 Túnel VPS: {'OK' if activos and activos[2]=='active' else 'caído'}", chat_id)
elif t == "reboot" or t == "/reboot":
enviar("⚠️ Para reiniciar la Pi responde <b>/confirmar-reboot</b> en 30 segundos.", chat_id)
elif t == "confirmar-reboot" or t == "/confirmar-reboot":
enviar("🔄 Reiniciando la Pi... volveré en un momento.", chat_id)
log("REBOOT solicitado")
sh("echo 'raspberry' | sudo -S reboot")
def monitor_temperatura():