fix(stats): add lib/stats.sh to bootstrap + auto-recreate history

Bug report: 'статистика не работает' — submenu_stats showed the
'stats module missing' fallback even though gotelegram-stats.service
was active. Root cause: bootstrap.sh FILES[] never included
lib/stats.sh, so on every (re)install the file was absent from
/opt/gotelegram/lib/ on disk. The running collector was sourcing it
from an in-memory bash process from a previous install, but
install.sh's `source stats.sh` at menu entry failed silently and
hit the 'stats_module_missing' branch.

Also: stats_collect silently skipped history writes if
stats_history.csv was deleted post-init (only stats_init created it
once). Now stats_collect auto-recreates the file with header.

- bootstrap.sh: add 'lib/stats.sh' to FILES[]
- lib/stats.sh: stats_collect auto-creates HISTORY_FILE if missing

Tested live on VPS: show_traffic_stats now outputs real counters
(23.1 MB proxy, 10 MB site, 394 KB/s peak).
This commit is contained in:
anten-ka
2026-04-10 12:44:35 +03:00
parent 6dc0000013
commit 6b206a1697
2 changed files with 414 additions and 0 deletions

1
bootstrap.sh Executable file → Normal file
View File

@@ -76,6 +76,7 @@ FILES=(
"lib/backup.sh"
"lib/website.sh"
"lib/templates_catalog.sh"
"lib/stats.sh"
"lib/i18n.sh"
"lib/lang/en.sh"
"lib/lang/ru.sh"