Files
buryan-infra/ops/mqtt/start_mqtt.py
buryan-agent 91eef1390a MQTT-брокер, Frigate в HA и новый ключ Jellyfin
Mosquitto 2 в CT 107 (порт 1883, пароли для frigate/homeassistant/hub),
проверено публикацией. Frigate переключён на этот брокер, API найден на
192.168.1.126:5000 (не .110), порты 5000/8971/8554/8555 проброшены.

HA: добавлены интеграции mqtt и frigate. Frigate-интеграция не вставала:
требование hass-web-proxy-lib==0.0.8 требует Python 3.14, в HA 3.13 —
поставили 0.0.7 и поправили манифест.

Jellyfin: старый ключ отдавал 401. Получен новый через логин akadmin и
POST /Auth/Keys (нужен заголовок Authorization: MediaBrowser Token="..."),
проверен по /Items/Counts, прописан в bots.env.
2026-10-20 19:13:42 +03:00

46 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Запускает mosquitto с конфигом."""
import subprocess
CT = "107"
def run(cmd, timeout=180):
r = subprocess.run(["pct", "exec", CT, "--", "bash", "-c", cmd],
capture_output=True, text=True, timeout=timeout)
return (r.stdout or r.stderr or "").strip()
CONF = """listener 1883 0.0.0.0
allow_anonymous false
password_file /mosquitto/config/passwd
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
log_type error
log_type warning
log_type notice
"""
with open("/tmp/mosquitto.conf", "w") as f:
f.write(CONF)
subprocess.run(["pct", "push", CT, "/tmp/mosquitto.conf",
"/opt/network-lxc/mosquitto/config/mosquitto.conf", "--perms", "644"],
capture_output=True, text=True)
print(" конфиг записан")
run("chown -R 1883:1883 /opt/network-lxc/mosquitto 2>/dev/null || true")
run("docker rm -f mosquitto 2>/dev/null || true")
out = run("docker run -d --name mosquitto --restart unless-stopped --network host "
"-v /opt/network-lxc/mosquitto/config:/mosquitto/config "
"-v /opt/network-lxc/mosquitto/data:/mosquitto/data "
"-v /opt/network-lxc/mosquitto/log:/mosquitto/log "
"eclipse-mosquitto:2", timeout=240)
print(" запуск:", out[:60])
import time
time.sleep(8)
print(" статус:", run("docker ps --filter name=mosquitto --format '{{.Status}}'"))
print(" порт:", run("ss -ltn | grep 1883 | head -2"))
print(" лог:", run("docker logs --tail 5 mosquitto 2>&1"))