Actualiser run.sh

Signed-off-by: thomas <contact@thomasmlg.fr>
This commit is contained in:
2026-03-05 15:18:40 +01:00
parent 2e79cca684
commit 90fc0d99d1

38
run.sh
View File

@@ -1,10 +1,19 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
# 🧹 Nettoyage écran (uniquement si on a un terminal) # 🧹 Nettoyage écran
if [[ -t 1 ]]; then clear
clear
fi LOG_DIR="/var/log/lxc-updater-TM"
LOG_FILE="${LOG_DIR}/lxc-updater-run.log"
mkdir -p "$LOG_DIR"
: > "$LOG_FILE"
log() {
echo "$1"
echo "$1" >> "$LOG_FILE"
}
BASE="https://git.thomasmlg.fr/thomas/Docker/raw/branch/release" BASE="https://git.thomasmlg.fr/thomas/Docker/raw/branch/release"
DIR="/opt/lxc-updater" DIR="/opt/lxc-updater"
@@ -12,25 +21,18 @@ DIR="/opt/lxc-updater"
mkdir -p "$DIR" mkdir -p "$DIR"
cd "$DIR" cd "$DIR"
# 🧾 Tout logguer dans un fichier dès le début (run + update) log "🧰 Téléchargement des scripts"
LOG="/var/log/lxc-updater-run.log"
mkdir -p /var/log
: > "$LOG"
# Redirige stdout/stderr vers le log, mais on garde laffichage console via exec 3 curl -fsSL "$BASE/detect.sh" -o detect.sh >>"$LOG_FILE" 2>&1
exec 3>&1 1>>"$LOG" 2>&1 curl -fsSL "$BASE/update.sh" -o update.sh >>"$LOG_FILE" 2>&1
echo "🧰 Téléchargement des scripts..." >&3
curl -fsSL "$BASE/detect.sh" -o detect.sh
curl -fsSL "$BASE/update.sh" -o update.sh
chmod +x detect.sh update.sh chmod +x detect.sh update.sh
METHOD="$(./detect.sh)" METHOD="$(./detect.sh)"
# ✅ Affichage demandé log "🧭 Mode de mise à jour : $METHOD"
echo "🧭 Mode de mise à jour : $METHOD" >&3
# Lance update (ses sorties console restent à lécran, et toutes les commandes vont au log interne) ./update.sh "$METHOD"
./update.sh "$METHOD" >&3
echo "🧾 Log run : $LOG" >&3 log "🧾 Log run : $LOG_FILE"
log "🎉 Script terminé"