Files
context-continuity/lint_weekly.sh
T

40 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/sh
# lint_weekly.sh - Execution hebdomadaire du Lint (etage 1 : lecture seule).
# Lance par le planificateur DSM le dimanche soir, utilisateur Master.
# lint_audit.py n ecrit RIEN dans Trilium : il produit un rapport dans lint_reports/.
# Ce wrapper : execute, fait tourner les rapports, sort UNE ligne pour le mail DSM.
BASE=/volume1/homes/Master/App/Context_continuity
PY=$BASE/venv/bin/python3
REPORTS=$BASE/lint_reports
GARDER=12 # ~3 mois d historique hebdomadaire
cd $BASE || { echo "ERREUR repertoire introuvable : $BASE"; exit 1; }
[ -x "$PY" ] || { echo "ERREUR venv introuvable : $PY"; exit 1; }
SORTIE=$($PY lint_audit.py 2>&1)
CODE=$?
if [ $CODE -ne 0 ]; then
echo "ERREUR lint_audit.py a echoue (code $CODE)"
echo "$SORTIE" | tail -5
exit 1
fi
# Extraire la synthese du rapport
TOTAL=$(echo "$SORTIE" | grep '^## Synthese' | sed 's/.*: \([0-9]*\) anomalie.*/\1/')
DIMS=$(echo "$SORTIE" | grep 'Par dimension' | sed 's/.*Par dimension : //')
BACS=$(echo "$SORTIE" | grep "Par bac d'action" | sed "s/.*Par bac d'action : //")
FICHIER=$(echo "$SORTIE" | grep '^Rapport ecrit' | sed 's/^Rapport ecrit : //')
# Rotation des rapports
if [ -d "$REPORTS" ]; then
cd $REPORTS && ls -1t lint_*.txt 2>/dev/null | tail -n +$((GARDER+1)) | while read f; do rm -f "$f"; done
fi
# Une ligne pour le mail DSM (le detail est dans le fichier)
if [ -z "$TOTAL" ]; then
echo "ERREUR synthese illisible dans la sortie du Lint"
exit 1
fi
echo "LINT $TOTAL anomalie(s) | $BACS | $DIMS | rapport: $FICHIER"