From fe7708f14294c670315257da2c085c1c26cc6978 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 9 Aug 2026 04:57:28 -0400 Subject: [PATCH] ai need continue --- DOC/AGENT_Context_Project.md | 8 +-- bin/pos-communication-telegram-listener | 12 ++-- bin/pos-system-backup | 1 + bin/pos-system-health | 82 +++---------------------- completions/pos.bash | 1 - postinstall.sh | 19 ------ systemd/pos-health.service | 11 ---- systemd/pos-health.timer | 9 --- 8 files changed, 21 insertions(+), 122 deletions(-) delete mode 100644 systemd/pos-health.service delete mode 100644 systemd/pos-health.timer diff --git a/DOC/AGENT_Context_Project.md b/DOC/AGENT_Context_Project.md index 0139958..1ee8714 100644 --- a/DOC/AGENT_Context_Project.md +++ b/DOC/AGENT_Context_Project.md @@ -553,7 +553,7 @@ Use conventional prefixes: `feat:`, `fix:`, `docs:`, `refactor:`, `chore:` | `features/autostart.sh` | 14 | Boot-time feature (moved from `bin/`, flag-gated service) | | `bin/pos` | 270 | CLI dispatcher with smart arg matching + logging + category help | -| `bin/pos-communication-telegram-listener` | 433 | Telegram bot listener: map /command → bash, run them on chat messages | +| `bin/pos-communication-telegram-listener` | 437 | Telegram bot listener: map /command → bash, run them on chat messages | | `bin/pos-communication-telegram-sender` | 270 | Send Telegram messages/files/links/stickers via Bot API (send, test, config set) | | `bin/pos-config` | 80 | Interactive editor for the tools' runtime config (reads # POS_CONFIG: registry) | | `bin/pos-docker-compose` | 366 | Docker Compose service manager (ls/up/down/restart/logs/update/config) | @@ -572,13 +572,13 @@ Use conventional prefixes: `feat:`, `fix:`, `docs:`, `refactor:`, `chore:` | `bin/pos-network-ip` | 69 | Show interfaces, routes, public IP + location | | `bin/pos-network-scan` | 271 | Parallel ping sweep of CIDR | | `bin/pos-ssh-load-keys` | 31 | Load all SSH keys into the agent | -| `bin/pos-system-backup` | 125 | Encrypted (AES-256) folder snapshots (tar + gpg) | +| `bin/pos-system-backup` | 126 | Encrypted (AES-256) folder snapshots (tar + gpg) | | `bin/pos-system-firewall` | 291 | Interactive UFW management | -| `bin/pos-system-health` | 275 | Host health dashboard (disk, RAM, services, backup age, fail2ban, docker); exit 1 if any FAIL | +| `bin/pos-system-health` | 209 | Host health dashboard (disk, RAM, services, backup age, fail2ban, docker); exit 1 if any FAIL | | `bin/pos-system-nfs-client` | 138 | Mount NFS shares (ephemeral or persistent systemd mount units) | | `bin/pos-system-nfs-server` | 134 | Manage the NFS kernel server (status, share/unshare exports, enable/disable) | | `bin/pos-usb-server` | 218 | USB Redirector server control (--ls, --share; prompts when args omitted) | -| `completions/pos.bash` | 279 | Dynamic bash completion | +| `completions/pos.bash` | 278 | Dynamic bash completion | | `apps/install.sh` | 171 | App install/uninstall picker/orchestrator | diff --git a/bin/pos-communication-telegram-listener b/bin/pos-communication-telegram-listener index 48badaa..1a7d1d6 100755 --- a/bin/pos-communication-telegram-listener +++ b/bin/pos-communication-telegram-listener @@ -32,7 +32,11 @@ Map: $MAP_FILE — one '/cmd=bash command' per line Prefix a map value with '@quiet ' to run the command without replying — for commands that already send their own notification, so you don't get it -twice (e.g. '/status=@quiet pos system health --send'). +twice (e.g. '/backup=@quiet pos system backup --send'). + +To reply with a command's stdout (e.g. the health dashboard), just map it +without '@quiet' and the listener forwards the output: + '/status=pos system health' The listener only reacts to the owner chat (TELEGRAM_CHAT_ID). Commands run as your user, so 'sudo' inside them needs a NOPASSWD rule. The interactive @@ -154,9 +158,9 @@ ui_pick() { } # Map entries may be prefixed with '@quiet ' to run the command without -# replying — for commands that deliver their own notification (e.g. the -# health check's --send). The marker is stripped before running and before -# the editor's bash -n syntax check. +# replying — for commands that deliver their own notification (e.g. backup's +# --send). The marker is stripped before running and before the editor's +# bash -n syntax check. QUIET_PREFIX="@quiet" strip_quiet() { diff --git a/bin/pos-system-backup b/bin/pos-system-backup index d3ef07e..dc754d0 100755 --- a/bin/pos-system-backup +++ b/bin/pos-system-backup @@ -2,6 +2,7 @@ set -euo pipefail # POS: system backup — Encrypted (AES-256) folder snapshots (tar + gpg) # POS_FLAGS: --service +# POS_CONFIG: notify | notify.env | NOTIFY_PLATFORM=:Comma-separated notify platforms (default telegram) — shared by backup, firewall, nfs-client and nfs-server source "$(dirname "$0")/../lib/common.sh" 2>/dev/null || source "$(dirname "$0")/common.sh" source "$(dirname "$0")/../lib/notify.sh" 2>/dev/null || source "$(dirname "$0")/notify.sh" diff --git a/bin/pos-system-health b/bin/pos-system-health index a31d3fb..1c0ba60 100755 --- a/bin/pos-system-health +++ b/bin/pos-system-health @@ -1,95 +1,64 @@ #!/usr/bin/env bash set -euo pipefail # POS: system health — Host health dashboard (disk, RAM, services, backup age, fail2ban, docker); exit 1 if any FAIL -# POS_FLAGS: --send --markdown # POS_CONFIG: system | system.env | BACKUP_SERVICE_ROOTS=:Roots scanned by backup --service and the health backup-age check (default: /srv $HOME/srv) | HEALTH_BACKUP_MAX_AGE_DAYS=num:Max backup age in days before health warns (default 2) -# POS_CONFIG: notify | notify.env | NOTIFY_PLATFORM=:Comma-separated notify platforms (default telegram) source "$(dirname "$0")/../lib/common.sh" 2>/dev/null || source "$(dirname "$0")/common.sh" -source "$(dirname "$0")/../lib/notify.sh" 2>/dev/null || source "$(dirname "$0")/notify.sh" load_system_env # Effective dynamic values (environment > system.env > defaults) shown in --help -EFF_PLATFORMS="$(notify_platforms)" EFF_MAX_AGE="${HEALTH_BACKUP_MAX_AGE_DAYS:-2}" EFF_ROOTS="${BACKUP_SERVICE_ROOTS:-/srv $HOME/srv}" usage() { cat <&1 - exec 1>/dev/null -fi - FAILURES=0 WARNINGS=0 -REPORT=() report() { - local st="$1" label="$2" detail="$3" line + local st="$1" label="$2" detail="$3" case "$st" in ok) echo " ${GREEN}${BOLD}[ OK ]${RESET} ${label}: ${detail}" - printf -v line "[ OK ] %s: %s" "$label" "$detail" ;; warn) echo " ${YELLOW}${BOLD}[WARN]${RESET} ${label}: ${detail}" - printf -v line "[WARN] %s: %s" "$label" "$detail" WARNINGS=$((WARNINGS + 1)) ;; fail) echo " ${RED}${BOLD}[FAIL]${RESET} ${label}: ${detail}" - printf -v line "[FAIL] %s: %s" "$label" "$detail" FAILURES=$((FAILURES + 1)) ;; esac - REPORT+=("$line") } host="$(hostname -s 2>/dev/null || echo "localhost")" @@ -237,39 +206,4 @@ else echo " ${GREEN}${BOLD}VERDICT${RESET} ${verdict}" fi -if [ "$SEND" -eq 1 ]; then - exec 1>&3 3>&- - msg="POS Health — ${host} -Verdict: ${verdict}" - for line in "${REPORT[@]}"; do - msg+=" -${line}" - done - if [ "$MARKDOWN" -eq 1 ]; then - notify_send "$msg" --markdown - else - notify_send "$msg" - fi - # notify_send is silent-fail by design — confirm delivery only when a - # platform sender actually exists, otherwise warn on stderr (still visible - # here since only stdout was redirected while --send ran). - delivered=0 - IFS=',' read -r -a platforms <<< "$(notify_platforms)" - for p in "${platforms[@]}"; do - p="${p// /}" - [ -n "$p" ] || continue - sname="$(notify_sender_name "$p")" - if command -v "pos-communication-$sname" &>/dev/null \ - || [ -x "$(dirname "$0")/pos-communication-$sname" ] \ - || [ -x "$(dirname "$0")/../bin/pos-communication-$sname" ]; then - delivered=1 - fi - done - if [ "$delivered" -eq 1 ]; then - echo "sent: POS Health — ${host} (${verdict})" - else - warn "notify: no platform sender found (NOTIFY_PLATFORM=$(notify_platforms)) — digest not delivered" - fi -fi - [ "$FAILURES" -eq 0 ] diff --git a/completions/pos.bash b/completions/pos.bash index 6a54897..7a0963d 100644 --- a/completions/pos.bash +++ b/completions/pos.bash @@ -8,7 +8,6 @@ _pos_flags[communication-telegram-sender]="--type --caption --parse-mode --no-pr _pos_flags[entertainment-send]="--print --markdown" _pos_flags[network-hotspot]="--foreground" _pos_flags[system-backup]="--service" -_pos_flags[system-health]="--send --markdown" _pos_flags[usb-server]="--ls --ls-shared --share --unshare --auto-share --callback --close-callback --auto-connect --disconnect --nickname --timeout --port --info --version" # GEN:END posflags # GEN:START possubcmds diff --git a/postinstall.sh b/postinstall.sh index ee8086b..36ec8e7 100755 --- a/postinstall.sh +++ b/postinstall.sh @@ -114,13 +114,6 @@ if [ -d systemd ] && [ -n "$(ls -A systemd/*.service 2>/dev/null)" ]; then fi run sudo systemctl daemon-reload - # pos-health.service runs as the installing user so the digest uses that - # user's real Telegram config. The timer is enabled only when a telegram.env - # is configured — re-run postinstall after configuring Telegram to pick it up. - DIGEST_USER="${SUDO_USER:-$USER}" - DIGEST_HOME="$(getent passwd "$DIGEST_USER" 2>/dev/null | cut -d: -f6)" - DIGEST_HOME="${DIGEST_HOME:-$HOME}" - for svc in systemd/*.service; do svc_name=$(basename "$svc") # autostart.service runs features/autostart.sh — enable only when @@ -129,18 +122,6 @@ if [ -d systemd ] && [ -n "$(ls -A systemd/*.service 2>/dev/null)" ]; then warn "autostart feature not installed — skipping autostart.service (run ./install.sh --feature)" continue fi - if [ "$svc_name" = "pos-health.service" ]; then - run sudo sed -i "s|__POS_USER__|$DIGEST_USER|" "/etc/systemd/system/$svc_name" - run sudo systemctl daemon-reload - if [ -f "$DIGEST_HOME/.config/linux_post_install/telegram.env" ]; then - run sudo systemctl enable --now pos-health.timer 2>/dev/null || \ - run sudo systemctl enable pos-health.timer - log "Daily health digest timer enabled for $DIGEST_USER" - else - warn "Telegram not configured — skipping health digest timer (run 'pos communication telegram sender config set ...' then re-run postinstall)" - fi - continue - fi run sudo systemctl enable --now "$svc_name" 2>/dev/null || \ run sudo systemctl enable "$svc_name" done diff --git a/systemd/pos-health.service b/systemd/pos-health.service deleted file mode 100644 index 570a300..0000000 --- a/systemd/pos-health.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=POS Health digest (daily report via configured notify platforms) -After=network-online.target -Wants=network-online.target - -[Service] -Type=oneshot -User=__POS_USER__ -EnvironmentFile=-%h/.config/linux_post_install/system.env -EnvironmentFile=-%h/.config/linux_post_install/notify.env -ExecStart=/usr/local/bin/pos system health --send --markdown diff --git a/systemd/pos-health.timer b/systemd/pos-health.timer deleted file mode 100644 index ca23f13..0000000 --- a/systemd/pos-health.timer +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=Daily POS health digest timer - -[Timer] -OnCalendar=*-*-* 08:00:00 -Persistent=true - -[Install] -WantedBy=timers.target