Newer
Older
gnexus-book / 10-systems / bots / mardisopsbot.md

title: MardisOpsBot description: Telegram ops bot for monitoring and controlling mardisbot.service host: tg_bots-vm status: active last_reviewed: 2026-09-10 owner: gmikcon confidence: 100 review_interval: 90

source_of_truth: live_system

MardisOpsBot

Telegram ops bot for monitoring and controlling mardisbot.service (see 10-systems/bots/mardisbot.md).

Naming warning: there are TWO similarly named hosts. This bot lives on the VM tg_bots (192.168.1.254, hostname tgbots) — NOT on the external VPS tgbots (192.168.1.178, hostname vmk).

Live deployment (deployed and verified 2026-09-10)

  • Host: VM tg_bots, 192.168.1.254 (libvirt on bserv 192.168.1.130)
  • User: ubuntu (password in gnexus-creds secret "tgbots"; sudo uses the same password)
  • Project Path: /home/ubuntu/bots/MardisOpsBot
  • Main Script: bot.py (venv: /home/ubuntu/bots/MardisOpsBot/venv, Python 3.10)
  • Config: .env in project dir (bot token, not documented here)
  • Dependencies: python-telegram-bot 22.8, python-dotenv, apscheduler (requirements.txt; pip 26.2.1 in venv)

systemd service

  • Service Name: mardisops.service — active (running), enabled
  • Unit File: /etc/systemd/system/mardisops.service
  • Deployed: 2026-09-10 07:08 UTC (Main PID verified running)
  • Hardening note: NoNewPrivileges=true was removed from the unit on 2026-09-10 07:12 UTC — it blocked sudo inside the service ("no new privileges" error, rc=1 on /status). Do not re-add it while the bot relies on sudo for systemctl/journalctl.

sudoers grant

  • /etc/sudoers.d/99-mardisops-sudoers (root:root, 0440, visudo -c OK) allows user ubuntu NOPASSWD for: systemctl status/is-active/is-enabled/show mardisbot.service, systemctl restart mardisbot.service, and journalctl -u mardisbot.service *.

Access model

  • First 3 Telegram users who send /start become admins; user_ids are persisted in /home/ubuntu/bots/MardisOpsBot/admins.json (survives restarts). Everyone else is silently ignored.
  • As of 2026-09-10 07:12 UTC one admin is enrolled: user_id 78389352.

Service management

sudo systemctl status mardisops.service
sudo journalctl -u mardisops.service -f
sudo systemctl restart mardisops.service

Startup log (verified 2026-09-10)

  • ops bot starting; admins=[78389352] (max 3)
  • polling started