Wiki/scripts/cron-install.sh
Corentin JOGUET 1d71364c6e
Some checks are pending
CI / Lint bridge (Biome) (push) Waiting to run
CI / Type-check bridge (push) Blocked by required conditions
CI / Tests unit bridge (push) Blocked by required conditions
CI / Tests integration bridge (push) Blocked by required conditions
CI / Security scan (push) Waiting to run
CI / Docker build + healthcheck (push) Blocked by required conditions
feat(seed): add I4 forms publics + space etudiant + I5 healthcheck etendu
I4 — Forms publics + space etudiant :
- baserow/seed/seed_forms.py : cree forms publics sur attribution + intervention
  (saisie heures via lien sans compte). Form cree OK, field-options endpoint
  retourne 404 sur Baserow 1.30 — a investiguer (URL different selon version).
- docmost/setup/create-space-etudiant.py : cree space prive + invite etudiant
  + page Welcome template. Slug strict lettres+chiffres only (fix Docmost).

I5 — Ops :
- scripts/healthcheck.sh : check UI + API health (Docmost+Baserow), affiche
  status containers Docker. 4/4 OK en local.
- scripts/cron-install.sh : installe cron quotidien backup + healthcheck */5min.

Makefile : targets seed-baserow-forms, create-space-etudiant. Tous les targets
utilisent maintenant .venv/ local pour eviter pip systeme.

.gitignore : exclut .venv/ + __pycache__/.
2026-05-07 18:49:00 +02:00

37 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# scripts/cron-install.sh — installe le cron quotidien backup
# Usage : sudo ./scripts/cron-install.sh
set -euo pipefail
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
CRON_USER="${CRON_USER:-$(whoami)}"
CRON_FILE="/etc/cron.d/formation-hub"
if [ "$(id -u)" -ne 0 ]; then
echo "Run as root (sudo) pour ecrire dans /etc/cron.d/"
exit 1
fi
cat > "$CRON_FILE" <<EOF
# formation-hub — backup quotidien
# Genere par scripts/cron-install.sh
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAILTO=""
# Backup quotidien Docmost + Baserow + uploads (03:00 local time)
0 3 * * * $CRON_USER cd $REPO_DIR && ./scripts/backup.sh >> /var/log/formation-hub-backup.log 2>&1
# Healthcheck toutes les 5 minutes (logue uniquement les fails)
*/5 * * * * $CRON_USER cd $REPO_DIR && ./scripts/healthcheck.sh >/dev/null 2>&1 || logger -t formation-hub "healthcheck failed at \$(date -Iseconds)"
EOF
chmod 644 "$CRON_FILE"
echo "Cron installe : $CRON_FILE"
echo ""
echo "Verification :"
cat "$CRON_FILE"
echo ""
echo "Pour test manuel : sudo -u $CRON_USER cd $REPO_DIR && ./scripts/backup.sh"
echo "Logs backup : tail -f /var/log/formation-hub-backup.log"