53
run.sh
53
run.sh
@@ -1,38 +1,45 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# 🧹 Nettoyage écran
|
# 🧼 Nettoyage écran
|
||||||
clear
|
clear
|
||||||
|
|
||||||
LOG_DIR="/var/log/lxc-updater-TM"
|
BASE_URL="https://git.thomasmlg.fr/thomas/Docker/raw/branch/release"
|
||||||
LOG_FILE="${LOG_DIR}/lxc-updater-run.log"
|
WORKDIR="/opt/lxc-updater"
|
||||||
|
|
||||||
mkdir -p "$LOG_DIR"
|
# 📁 Logs par date
|
||||||
: > "$LOG_FILE"
|
LOG_ROOT="/var/log/lxc-updater-TM"
|
||||||
|
DATE="$(date +%F)"
|
||||||
|
TS="$(date +%H%M%S)"
|
||||||
|
LOG_DIR="${LOG_ROOT}/${DATE}"
|
||||||
|
RUN_LOG="${LOG_DIR}/lxc-updater-run.log"
|
||||||
|
RUN_LOG_ARCHIVE="${LOG_DIR}/lxc-updater-run-${TS}.log"
|
||||||
|
|
||||||
|
mkdir -p "$WORKDIR" "$LOG_DIR"
|
||||||
|
: > "$RUN_LOG"
|
||||||
|
: > "$RUN_LOG_ARCHIVE"
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
echo "$1"
|
echo "$1"
|
||||||
echo "$1" >> "$LOG_FILE"
|
echo "$1" >>"$RUN_LOG"
|
||||||
|
echo "$1" >>"$RUN_LOG_ARCHIVE"
|
||||||
}
|
}
|
||||||
|
|
||||||
BASE="https://git.thomasmlg.fr/thomas/Docker/raw/branch/release"
|
log "🧰 LXC Updater (TM)"
|
||||||
DIR="/opt/lxc-updater"
|
log "🖥️ Conteneur : $(hostname)"
|
||||||
|
log "📅 Date : ${DATE} 🕒 Heure : ${TS}"
|
||||||
|
|
||||||
mkdir -p "$DIR"
|
log "⬇️ Téléchargement des scripts..."
|
||||||
cd "$DIR"
|
curl -fsSL "${BASE_URL}/detect.sh" -o "${WORKDIR}/detect.sh" >>"$RUN_LOG" 2>&1
|
||||||
|
curl -fsSL "${BASE_URL}/update.sh" -o "${WORKDIR}/update.sh" >>"$RUN_LOG" 2>&1
|
||||||
|
chmod +x "${WORKDIR}/detect.sh" "${WORKDIR}/update.sh"
|
||||||
|
|
||||||
log "🧰 Téléchargement des scripts"
|
MODE="$("${WORKDIR}/detect.sh")"
|
||||||
|
log "🧭 Mode de mise à jour : ${MODE}"
|
||||||
|
|
||||||
curl -fsSL "$BASE/detect.sh" -o detect.sh >>"$LOG_FILE" 2>&1
|
log "🚀 Lancement de la mise à jour..."
|
||||||
curl -fsSL "$BASE/update.sh" -o update.sh >>"$LOG_FILE" 2>&1
|
"${WORKDIR}/update.sh" "${MODE}"
|
||||||
|
|
||||||
chmod +x detect.sh update.sh
|
log "🧾 Log run : ${RUN_LOG}"
|
||||||
|
log "🗃️ Archive run : ${RUN_LOG_ARCHIVE}"
|
||||||
METHOD="$(./detect.sh)"
|
log "🎉 Terminé"
|
||||||
|
|
||||||
log "🧭 Mode de mise à jour : $METHOD"
|
|
||||||
|
|
||||||
./update.sh "$METHOD"
|
|
||||||
|
|
||||||
log "🧾 Log run : $LOG_FILE"
|
|
||||||
log "🎉 Script terminé"
|
|
||||||
Reference in New Issue
Block a user