Files
lampac/scripts/install-git-hooks.sh
prodik 25c591b45a Секреты вынесены в config/init.custom.conf + config/secrets.env
- config/init.conf — шаблон (секреты всегда пустые), в git
- config/init.custom.conf — боевой конфиг, монтируется в /lampac/init.conf,
  собирается scripts/config-secrets.py apply из шаблона + secrets.env
- docker-compose.yaml: монтирует ./config/init.custom.conf:/lampac/init.conf
- scripts/config-secrets.py: apply/export/check/status
- scripts/install-git-hooks.sh: post-merge/post-checkout -> apply,
  pre-commit -> check --staged
- scripts/restore-lampa-main.sh: восстановление веб-клиента из архива
- .gitignore: init.custom.conf, secrets.env, lampa-main/, restore.sh zip
- lampa-main смонтирован как bind-mount ./lampa-main:/lampac/wwwroot/lampa-main,
  переживает docker compose up -d (раньше исчезал из writable-слоя)
- README: раздел «Секреты», обновлена «Структура проекта» и «Обновление»,
  «Безопасность» переписана под новую схему
- AGENT: правило 10 дополнено init.custom.conf/secrets.env/хуками,
  §11 Tg-notify ссылается на apply, §1 упоминает lampa-main bind-mount
2026-10-04 15:42:16 +00:00

26 lines
829 B
Bash

#!/usr/bin/env bash
# Вешает git-хуки, которые держат секреты вне git.
# post-merge / post-checkout -> apply (собирает config/init.custom.conf)
# pre-commit -> check (отменяет коммит с секретами)
set -e
cd "$(git rev-parse --show-toplevel)"
mkdir -p .git/hooks
cat > .git/hooks/post-merge <<'H'
#!/bin/sh
exec python3 scripts/config-secrets.py apply
H
cat > .git/hooks/post-checkout <<'H'
#!/bin/sh
exec python3 scripts/config-secrets.py apply
H
cat > .git/hooks/pre-commit <<'H'
#!/bin/sh
exec python3 scripts/config-secrets.py check --staged
H
chmod +x .git/hooks/post-merge .git/hooks/post-checkout .git/hooks/pre-commit
echo "хуки установлены:"
ls -l .git/hooks/post-merge .git/hooks/post-checkout .git/hooks/pre-commit