38
run.sh
38
run.sh
@@ -1,10 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# 🧹 Nettoyage écran (uniquement si on a un terminal)
|
||||
if [[ -t 1 ]]; then
|
||||
clear
|
||||
fi
|
||||
# 🧹 Nettoyage écran
|
||||
clear
|
||||
|
||||
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"
|
||||
DIR="/opt/lxc-updater"
|
||||
@@ -12,25 +21,18 @@ DIR="/opt/lxc-updater"
|
||||
mkdir -p "$DIR"
|
||||
cd "$DIR"
|
||||
|
||||
# 🧾 Tout logguer dans un fichier dès le début (run + update)
|
||||
LOG="/var/log/lxc-updater-run.log"
|
||||
mkdir -p /var/log
|
||||
: > "$LOG"
|
||||
log "🧰 Téléchargement des scripts"
|
||||
|
||||
# Redirige stdout/stderr vers le log, mais on garde l’affichage console via exec 3
|
||||
exec 3>&1 1>>"$LOG" 2>&1
|
||||
curl -fsSL "$BASE/detect.sh" -o detect.sh >>"$LOG_FILE" 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
|
||||
|
||||
METHOD="$(./detect.sh)"
|
||||
|
||||
# ✅ Affichage demandé
|
||||
echo "🧭 Mode de mise à jour : $METHOD" >&3
|
||||
log "🧭 Mode de mise à jour : $METHOD"
|
||||
|
||||
# Lance update (ses sorties console restent à l’écran, et toutes les commandes vont au log interne)
|
||||
./update.sh "$METHOD" >&3
|
||||
./update.sh "$METHOD"
|
||||
|
||||
echo "🧾 Log run : $LOG" >&3
|
||||
log "🧾 Log run : $LOG_FILE"
|
||||
log "🎉 Script terminé"
|
||||
Reference in New Issue
Block a user