update-iventoy.sh aktualisiert

This commit is contained in:
2026-09-07 01:19:06 +02:00
parent 7482222d52
commit c618e384cc
+110 -67
View File
@@ -12,9 +12,10 @@ CONFIG_FILE="${CONFIG_DIR}/config.dat"
SERVICE="iventoy"
TMP="/tmp/iventoy-update"
GITHUB_REPO="ventoy/PXE"
MAX_BACKUPS=10
echo "=========================================="
echo " iVentoy Update"
echo "=========================================="
@@ -43,38 +44,10 @@ apt-get install -y -qq curl tar >/dev/null
mkdir -p "$ISO_DIR"
mkdir -p "$CONFIG_DIR"
# --------------------------------------------------
# Existing config sichern / initial übernehmen
# --------------------------------------------------
if [ ! -f "$CONFIG_FILE" ]; then
if [ -f "${CURRENT}/data/config.dat" ]; then
echo "Übernehme bestehende iVentoy Config..."
cp -a "${CURRENT}/data/config.dat" "$CONFIG_FILE"
else
echo "WARNUNG: Keine bestehende config.dat gefunden."
fi
fi
# Backup
if [ -f "$CONFIG_FILE" ]; then
BACKUP="${CONFIG_FILE}.bak-$(date +%Y%m%d-%H%M%S)"
echo "Sichere Config nach:"
echo " $BACKUP"
cp -a "$CONFIG_FILE" "$BACKUP"
fi
# --------------------------------------------------
# Latest Version ermitteln
# --------------------------------------------------
echo
echo "Ermittle aktuelle iVentoy-Version..."
LATEST_TAG=$(
@@ -92,45 +65,101 @@ if [ -z "$VERSION" ]; then
exit 1
fi
echo "Neueste Version: $VERSION"
TARGET="${BASE}/iventoy-${VERSION}"
echo "Neueste Version: $VERSION"
# --------------------------------------------------
# Prüfen ob bereits installiert
# Prüfen ob bereits aktuell
# --------------------------------------------------
if [ -L "$CURRENT" ]; then
CURRENT_TARGET=$(readlink -f "$CURRENT" || true)
if [ "$CURRENT_TARGET" = "$TARGET" ]; then
echo
echo "=========================================="
echo " iVentoy ist bereits aktuell"
echo "=========================================="
echo
echo "Aktive Version: $VERSION"
echo "Installation: $CURRENT -> $TARGET"
echo
exit 0
fi
fi
# --------------------------------------------------
# Bestehende Config übernehmen
# --------------------------------------------------
if [ ! -f "$CONFIG_FILE" ]; then
if [ -f "${CURRENT}/data/config.dat" ]; then
echo
echo "Übernehme bestehende iVentoy Config..."
cp -a "${CURRENT}/data/config.dat" "$CONFIG_FILE"
else
echo
echo "WARNUNG: Keine bestehende config.dat gefunden."
fi
fi
# --------------------------------------------------
# Config Backup
# --------------------------------------------------
if [ -f "$CONFIG_FILE" ]; then
BACKUP="${CONFIG_FILE}.bak-$(date +%Y%m%d-%H%M%S)"
echo
echo "Sichere Config:"
echo " $BACKUP"
cp -a "$CONFIG_FILE" "$BACKUP"
# --------------------------------------------------
# Backup Rotation
# --------------------------------------------------
echo "Behalte maximal ${MAX_BACKUPS} Config-Backups..."
find "$CONFIG_DIR" \
-maxdepth 1 \
-type f \
-name 'config.dat.bak-*' \
-printf '%T@ %p\n' \
| sort -nr \
| tail -n +"$((MAX_BACKUPS + 1))" \
| cut -d' ' -f2- \
| xargs -r rm -f
fi
# --------------------------------------------------
# Download / Entpacken
# --------------------------------------------------
if [ -d "$TARGET" ]; then
echo
echo "Version $VERSION ist bereits unter"
echo "Version $VERSION ist bereits vorhanden:"
echo " $TARGET"
echo "vorhanden."
else
# --------------------------------------------------
# Download
# --------------------------------------------------
rm -rf "$TMP"
mkdir -p "$TMP"
ARCHIVE="iventoy-${VERSION}-linux-x86_64-free.tar.gz"
URL="https://github.com/${GITHUB_REPO}/releases/download/v${VERSION}/${ARCHIVE}"
echo
echo "Lade herunter:"
echo " $URL"
curl -fL \
"$URL" \
-o "${TMP}/${ARCHIVE}"
# --------------------------------------------------
# Entpacken
# --------------------------------------------------
curl -fL "$URL" -o "${TMP}/${ARCHIVE}"
echo
echo "Entpacke iVentoy..."
@@ -140,7 +169,8 @@ else
EXTRACTED="${TMP}/iventoy-${VERSION}"
if [ ! -d "$EXTRACTED" ]; then
echo "ERROR: Erwartetes Verzeichnis $EXTRACTED nicht gefunden."
echo "ERROR: Erwartetes Verzeichnis wurde nicht gefunden:"
echo " $EXTRACTED"
exit 1
fi
@@ -149,26 +179,25 @@ else
fi
# --------------------------------------------------
# Symlinks vorbereiten
# ISO Symlink
# --------------------------------------------------
echo
echo "Setze persistente Verzeichnisse..."
# ISO
echo "Setze ISO-Symlink..."
rm -rf "${TARGET}/iso"
ln -s "$ISO_DIR" "${TARGET}/iso"
# Config
# --------------------------------------------------
# Config Symlink
# --------------------------------------------------
if [ -f "$CONFIG_FILE" ]; then
rm -f "${TARGET}/data/config.dat"
echo "Setze Config-Symlink..."
ln -s \
"$CONFIG_FILE" \
"${TARGET}/data/config.dat"
rm -f "${TARGET}/data/config.dat"
ln -s "$CONFIG_FILE" "${TARGET}/data/config.dat"
fi
@@ -184,14 +213,9 @@ systemctl stop "$SERVICE" 2>/dev/null || true
sleep 2
# --------------------------------------------------
# Bestehende /opt/iventoy Installation migrieren
# Alte direkte Installation sichern
# --------------------------------------------------
#
# Falls /opt/iventoy beim allerersten Lauf noch ein echtes
# Verzeichnis und kein Symlink ist.
#
if [ -e "$CURRENT" ] && [ ! -L "$CURRENT" ]; then
OLD="${BASE}/iventoy-old-$(date +%Y%m%d-%H%M%S)"
@@ -215,7 +239,7 @@ ln -sfn "$TARGET" "${CURRENT}.new"
mv -Tf "${CURRENT}.new" "$CURRENT"
# --------------------------------------------------
# Start
# Service starten
# --------------------------------------------------
echo
@@ -246,19 +270,35 @@ if ! ss -lntH | awk '{print $4}' | grep -Eq '[:.]16000$'; then
FAILED=1
fi
if ! ss -lnuH | awk '{print $4}' | grep -Eq '[:.]69$'; then
echo "ERROR: UDP 69 lauscht nicht."
FAILED=1
fi
if ! ss -lnuH | awk '{print $4}' | grep -Eq '[:.]4011$'; then
echo "ERROR: UDP 4011 lauscht nicht."
FAILED=1
fi
if ! ss -lnuH | awk '{print $4}' | grep -Eq '[:.]67$'; then
echo "ERROR: UDP 67 lauscht nicht."
FAILED=1
fi
if [ "$FAILED" -ne 0 ]; then
echo
echo "=========================================="
echo " UPDATE FEHLGESCHLAGEN"
echo "=========================================="
echo
echo "iVentoy Log:"
tail -n 40 "${CURRENT}/log/log.txt" || true
if [ -f "${CURRENT}/log/log.txt" ]; then
echo "Letzte iVentoy Log-Einträge:"
tail -n 40 "${CURRENT}/log/log.txt" || true
fi
exit 1
fi
# --------------------------------------------------
@@ -283,4 +323,7 @@ echo " ${CURRENT}/data/config.dat -> $CONFIG_FILE"
echo
echo "ISO:"
echo " ${CURRENT}/iso -> $ISO_DIR"
echo
echo "Config-Backups:"
echo " maximal $MAX_BACKUPS"
echo