From a14d35bec7114831ab0aa9921df31cf2a599eaa4 Mon Sep 17 00:00:00 2001 From: thomas Date: Tue, 10 Mar 2026 17:55:52 +0100 Subject: [PATCH] Actualiser run.sh Signed-off-by: thomas --- run.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 46e47c8..ea0e2b5 100644 --- a/run.sh +++ b/run.sh @@ -21,12 +21,37 @@ log() { echo "$1" >>"$RUN_LOG_ARCHIVE" } +send_matrix() { + local message="$1" + + MATRIX_URL="https://element.thomasmlg.fr" + ROOM_ID="!qMftKWAtfFIQzithEu:malgouyres" + ACCESS_TOKEN="syt_YWRtaW4_HyZwdmZXmngmUNGdxgTV_0tb2UI" + + curl -s -X POST \ + -H "Authorization: Bearer ${ACCESS_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{ + \"msgtype\":\"m.text\", + \"body\":\"${message}\" + }" \ + "${MATRIX_URL}/_matrix/client/r0/rooms/${ROOM_ID}/send/m.room.message" \ + >/dev/null 2>&1 || true +} + +on_error() { + send_matrix "❌ Échec de la mise à jour sur $(hostname)" +} +trap on_error ERR + # ------------------------------------------------ # Téléchargement des scripts # ------------------------------------------------ clear -echo "🧰 LXC Updater (TM)" +echo "╔══════════════════════════════════════╗" +echo "║ LXC Updater (TM) ║" +echo "╚══════════════════════════════════════╝" echo "🖥️ Conteneur : $(hostname)" echo "📅 Date : ${DATE} 🕒 Heure : ${TS}" echo "" @@ -43,11 +68,24 @@ chmod +x "${WORKDIR}/detect.sh" "${WORKDIR}/update.sh" MODE="$("${WORKDIR}/detect.sh")" +# ------------------------------------------------ +# Notification début +# ------------------------------------------------ + +send_matrix "🔄 Mise à jour en cours sur $(hostname)" + # ------------------------------------------------ # ÉTAPE 1 — Mise à jour du système # ------------------------------------------------ clear +echo "╔══════════════════════════════════════╗" +echo "║ LXC Updater (TM) ║" +echo "╚══════════════════════════════════════╝" +echo "🖥️ Conteneur : $(hostname)" +echo "📅 Date : ${DATE} 🕒 Heure : ${TS}" +echo "📌 Étape : Mise à jour du système" +echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "📦 Mise à jour du système" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" @@ -62,6 +100,13 @@ sleep 2 # ------------------------------------------------ clear +echo "╔══════════════════════════════════════╗" +echo "║ LXC Updater (TM) ║" +echo "╚══════════════════════════════════════╝" +echo "🖥️ Conteneur : $(hostname)" +echo "📅 Date : ${DATE} 🕒 Heure : ${TS}" +echo "📌 Étape : Mise à jour des conteneurs Docker" +echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "🐳 Mise à jour des conteneurs Docker" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" @@ -76,4 +121,6 @@ echo "" echo "" echo "🧾 Log run : ${RUN_LOG}" echo "🗃️ Archive run : ${RUN_LOG_ARCHIVE}" -echo "🎉 Terminé" \ No newline at end of file +echo "🎉 Terminé" + +send_matrix "✅ Mise à jour terminée avec succès sur $(hostname)" \ No newline at end of file