#!/usr/bin/env bash # lib-notify.sh — notification Matrix en payload JSON structuré (C-AP2). # Identifiants : /etc/restic/matrix.env sur le G9 (600 root, jamais affichés, jamais copiés ici). # Usage : source lib-notify.sh puis notify_json '' (ou notify_simple ) # Pattern d'envoi identique à restic-notify.sh : Bearer + room URL-encodé + PUT avec txnId. G9_SSH="${G9_SSH:-folzo@192.168.1.24}" G9_SSH_KEY="${G9_SSH_KEY:-$HOME/.ssh/id_ed25519_openfox11}" notify_json() { local payload="$1" b64 if [ -z "$payload" ]; then echo "NOTIFY_KO no-payload" return 1 fi b64="$(printf '%s' "$payload" | base64 -w0)" # sudo ne transmet pas l'environnement (sudoers sans SETENV) : payload et URL # passent en arguments, pas en variables exportées. ssh -o ConnectTimeout=8 -o BatchMode=yes -i "$G9_SSH_KEY" "$G9_SSH" \ "sudo python3 /usr/local/bin/g9-notify.py '$b64' '$(cat "$HOME/.config/g9-migration/hub_url" 2>/dev/null)'" 2>&1 | tail -1 } notify_simple() { local source="$1" brique="$2" severity="$3" message="$3" : }