Files
Vlad Gothbreach af292ff15d
checks / pytest (push) Has been cancelled
checks / moderation (push) Has been cancelled
checks / node (push) Has been cancelled
Harden entry safety, unify runtime config, bound document unpacking
Shared-IP safety: entry autoban and entry notifications default off, and a
shared IP is treated as review evidence only. ban_user/ban_cluster refuse
reason=entry_ip_collision (also with the legacy flag set to 1), so token status
and quota are never touched; explicit admin moderation still works.

Reproducible startup: new bot/runtime_config.py and scripts/run.py load the
repository .env (or --env-file) without shell interpolation, normalize
config/DB/upstream aliases, and make the bot, Mini App, gateway, econ cap,
account admin, mk_daemon, entry admin and key notifications resolve the same
paths. "run.py <target> --check" is an offline preflight that starts nothing
and reports placeholders, missing upstream DB and invalid data directories.

Resource limits: aggregate Office decompression, a 400 read-entry cap and a
per-row XLSX cell budget stop early; truncated or corrupt archives are
reported instead of raising.

Deploy and docs: only source-backed systemd units remain, and
deploy/runtime.env.example documents the environment contract including the
0600 session-secret file rules. Removed the destructive
"cp bot/iishko_bot.py bot/grok_bot.py" instruction, the unused generated site/
snapshot and the unsupported iishko-ts staging unit; corrected .env.example,
README, ARCHITECTURE, SECURITY, docs/native-gateway.md and iishko-ts/README.md.

Tests: entry safety, runtime bootstrap, economy paths, file intake, deploy
contract, abilities_guard CLI, and a startup smoke that launches all three
components through scripts/run.py with non-loopback network blocked. Every
config reader, selfcheck included, accepts a UTF-8 BOM.

Verified on this tree: pytest 716 passed + 322 subtests, node --test 73/73,
go test and go vet clean, selfcheck --source-only ok, gitleaks worktree and
history 0 findings. No production or live-split changes are included.
2026-10-31 00:39:35 +03:00

60 lines
2.8 KiB
Bash

# IISHKO runtime environment for systemd units.
#
# Install (never commit the real file):
# sudo install -d -m 0750 /etc/iishko
# sudo install -m 0640 -o root -g root \
# /opt/iishko/deploy/runtime.env.example /etc/iishko/runtime.env
# sudoedit /etc/iishko/runtime.env # replace every REPLACE_ME
#
# Consumers:
# deploy/systemd/grok-bot.service -> scripts/run.py bot --env-file /etc/iishko/runtime.env
# deploy/systemd/iishko-webapp.service -> scripts/run.py miniapp --env-file /etc/iishko/runtime.env
# deploy/systemd/grok-web-skin.service -> scripts/run.py gateway --env-file /etc/iishko/runtime.env
# deploy/systemd/iishko-moderation.service -> EnvironmentFile=/etc/iishko/runtime.env (Go binary)
#
# Priority: a variable already present in the process environment wins over the
# value in this file. scripts/run.py loads the file, normalises the legacy config
# aliases (GROK_BOT_CFG / GROK_BOT_CONFIG / GATE_BOT_CONFIG) and only then starts
# the target process; it does not override real environment variables.
#
# This file holds configuration only. Secrets live in bot/config.json (0600) and
# in this file — both stay outside the repository.
# --- bot config (canonical name; aliases are set by scripts/run.py) -----------
GROK_BOT_CFG=/etc/iishko/bot/config.json
# --- SQLite files (absolute; create the directory first) ---------------------
IISHKO_BOT_DB=/opt/iishko/var/bot.db
IISHKO_GW_DB=/opt/iishko/var/newapi.db
# Canonical skin DB name; GATE_TG_DB is the legacy alias for the same file.
IISHKO_SKIN_DB=/opt/iishko/var/grok-web-skin-tg.db
IISHKO_ECON_STATE=/opt/iishko/var/econ_cap_state.json
# --- loopback listeners (never expose these directly) -----------------------
IISHKO_WEBAPP_HOST=127.0.0.1
IISHKO_WEBAPP_PORT=8850
IISHKO_GATEWAY_HOST=127.0.0.1
IISHKO_GATEWAY_PORT=48001
# --- upstream gateway (New API / one-api, external service) ------------------
IISHKO_UPSTREAM=http://127.0.0.1:48000
# --- provider registry (operator-owned file, see gateway/providers.example.json)
IISHKO_PROVIDERS_FILE=/etc/iishko/providers.json
# --- moderation token (required by iishko-moderation, >=32 chars) ------------
IISHKO_MODERATION_TOKEN=REPLACE_ME_MODERATION_TOKEN
# --- admin Telegram IDs, comma separated ------------------------------------
IISHKO_ADMIN_IDS=
# --- Telegram website session-signing secret (never commit or overwrite) ----
# Leave the path absent on first start: gateway creates it atomically with mode 0600.
# Keep it outside the repo and preserve it across upgrades. An existing file must
# have mode 0600 and belong to the gateway service user; its contents are not printed.
TG_SID_SECRET_FILE=/etc/iishko/tg-sid-secret
# --- optional features, off by default (see deploy/README.md) ---------------
IISHKO_ENTRY_AUTOBAN=0
IISHKO_NOTIFICATIONS_ENABLED=0
IISHKO_SANDBOX_ENABLED=0