V4
This commit is contained in:
1 parent
6a1a247a39
commit
5c361d3c9c
1 file changed
+90
-19
+90
-19
@@ -28,6 +28,11 @@ ERRORS=0
|
|||||||
HOST_OK="not-run"
|
HOST_OK="not-run"
|
||||||
HOST_REBOOT_REQUIRED="no"
|
HOST_REBOOT_REQUIRED="no"
|
||||||
|
|
||||||
|
# Laufende Gäste, die nach erfolgreichem Update einen Neustart benötigen.
|
||||||
|
# Die Neustarts werden erst am Ende des gesamten Laufs entschieden.
|
||||||
|
LXC_REBOOT_PENDING=()
|
||||||
|
VM_REBOOT_PENDING=()
|
||||||
|
|
||||||
LXC_OK=0
|
LXC_OK=0
|
||||||
LXC_FAILED=0
|
LXC_FAILED=0
|
||||||
LXC_SKIPPED=0
|
LXC_SKIPPED=0
|
||||||
@@ -407,16 +412,10 @@ update_lxc() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$reboot_required" == "yes" ]]; then
|
if [[ "$reboot_required" == "yes" ]]; then
|
||||||
log "CT $id ($name): automatischer Neustart ..."
|
# Nicht sofort neu starten. Erst nach allen Updates entscheiden wir,
|
||||||
|
# ob ohnehin der Proxmox-Host neu gestartet wird.
|
||||||
if pct reboot "$id" --timeout 60; then
|
LXC_REBOOT_PENDING+=("$id")
|
||||||
log "CT $id ($name): Neustart erfolgreich ausgelöst."
|
log "CT $id ($name): Neustart vorgemerkt."
|
||||||
else
|
|
||||||
log "FEHLER: CT $id ($name) konnte nicht neu gestartet werden."
|
|
||||||
LXC_OK=$((LXC_OK - 1))
|
|
||||||
LXC_FAILED=$((LXC_FAILED + 1))
|
|
||||||
ERRORS=$((ERRORS + 1))
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,6 +501,63 @@ update_vm() {
|
|||||||
check_vm "$id"
|
check_vm "$id"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reboot_pending_guests() {
|
||||||
|
local id
|
||||||
|
local name
|
||||||
|
|
||||||
|
if (( ${#LXC_REBOOT_PENDING[@]} == 0 && ${#VM_REBOOT_PENDING[@]} == 0 )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
log ""
|
||||||
|
log "============================================================"
|
||||||
|
log " Erforderliche Gast-Neustarts"
|
||||||
|
log "============================================================"
|
||||||
|
|
||||||
|
for id in "${LXC_REBOOT_PENDING[@]}"; do
|
||||||
|
name="$(lxc_name "$id")"
|
||||||
|
name="${name:-unbekannt}"
|
||||||
|
|
||||||
|
if [[ "$(pct status "$id" 2>/dev/null | awk '{print $2}')" != "running" ]]; then
|
||||||
|
log "CT $id ($name): nicht mehr gestartet -> kein Neustart nötig."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "CT $id ($name): automatischer Neustart ..."
|
||||||
|
if pct reboot "$id" --timeout 60; then
|
||||||
|
log "CT $id ($name): Neustart erfolgreich ausgelöst."
|
||||||
|
else
|
||||||
|
log "FEHLER: CT $id ($name) konnte nicht neu gestartet werden."
|
||||||
|
LXC_OK=$((LXC_OK - 1))
|
||||||
|
LXC_FAILED=$((LXC_FAILED + 1))
|
||||||
|
ERRORS=$((ERRORS + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Für Linux-VMs ist die automatische Paketinstallation in dieser Version
|
||||||
|
# noch nicht freigeschaltet. Die Liste ist bereits vorgesehen, damit die
|
||||||
|
# gleiche Entscheidungslogik später ohne Umbau verwendet werden kann.
|
||||||
|
for id in "${VM_REBOOT_PENDING[@]}"; do
|
||||||
|
name="$(vm_name "$id")"
|
||||||
|
name="${name:-unbekannt}"
|
||||||
|
|
||||||
|
if [[ "$(qm status "$id" 2>/dev/null | awk '{print $2}')" != "running" ]]; then
|
||||||
|
log "VM $id ($name): nicht mehr gestartet -> kein Neustart nötig."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "VM $id ($name): automatischer Neustart ..."
|
||||||
|
if qm reboot "$id" >/dev/null 2>&1; then
|
||||||
|
log "VM $id ($name): Neustart erfolgreich ausgelöst."
|
||||||
|
else
|
||||||
|
log "FEHLER: VM $id ($name) konnte nicht neu gestartet werden."
|
||||||
|
VM_OK=$((VM_OK - 1))
|
||||||
|
VM_FAILED=$((VM_FAILED + 1))
|
||||||
|
ERRORS=$((ERRORS + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
list_lxc() {
|
list_lxc() {
|
||||||
pct list 2>/dev/null |
|
pct list 2>/dev/null |
|
||||||
awk 'NR>1 && $1 ~ /^[0-9]+$/ {print $1}'
|
awk 'NR>1 && $1 ~ /^[0-9]+$/ {print $1}'
|
||||||
@@ -608,16 +664,29 @@ log "============================================================"
|
|||||||
|
|
||||||
if [[ -z "$ONLY_CT" \
|
if [[ -z "$ONLY_CT" \
|
||||||
&& -z "$ONLY_VM" \
|
&& -z "$ONLY_VM" \
|
||||||
&& "$MODE" == "update" \
|
&& "$MODE" == "update" ]]
|
||||||
&& "$HOST_OK" == "yes" \
|
|
||||||
&& "$HOST_REBOOT_REQUIRED" == "yes" \
|
|
||||||
&& "$AUTO_REBOOT_HOST" == "yes" \
|
|
||||||
&& "$NO_REBOOT" != "yes" ]]
|
|
||||||
then
|
then
|
||||||
|
if (( ERRORS > 0 )); then
|
||||||
|
if [[ "$HOST_REBOOT_REQUIRED" == "yes" ]]; then
|
||||||
|
log ""
|
||||||
|
log "Host-Neustart erforderlich, aber automatischer Neustart wird NICHT ausgeführt."
|
||||||
|
log "Grund: $ERRORS Fehler im Update-Lauf."
|
||||||
|
fi
|
||||||
|
|
||||||
if (( ERRORS == 0 )); then
|
if (( ${#LXC_REBOOT_PENDING[@]} > 0 || ${#VM_REBOOT_PENDING[@]} > 0 )); then
|
||||||
|
log ""
|
||||||
|
log "Gast-Neustart erforderlich, aber automatische Gast-Neustarts werden NICHT ausgeführt."
|
||||||
|
log "Grund: $ERRORS Fehler im Update-Lauf."
|
||||||
|
fi
|
||||||
|
|
||||||
|
elif [[ "$HOST_OK" == "yes" \
|
||||||
|
&& "$HOST_REBOOT_REQUIRED" == "yes" \
|
||||||
|
&& "$AUTO_REBOOT_HOST" == "yes" \
|
||||||
|
&& "$NO_REBOOT" != "yes" ]]
|
||||||
|
then
|
||||||
log ""
|
log ""
|
||||||
log "Host-Neustart erforderlich."
|
log "Host-Neustart erforderlich."
|
||||||
|
log "Keine einzelnen CT/VM-Neustarts: der Host-Neustart übernimmt diese."
|
||||||
log "Gesamter Update-Lauf fehlerfrei."
|
log "Gesamter Update-Lauf fehlerfrei."
|
||||||
log "Automatischer Neustart in 1 Minute."
|
log "Automatischer Neustart in 1 Minute."
|
||||||
log "Proxmox fährt die laufenden Gäste geordnet herunter."
|
log "Proxmox fährt die laufenden Gäste geordnet herunter."
|
||||||
@@ -626,10 +695,12 @@ then
|
|||||||
|
|
||||||
shutdown -r +1 \
|
shutdown -r +1 \
|
||||||
"Proxmox Guest Updater: Neustart nach erfolgreichem Systemupdate"
|
"Proxmox Guest Updater: Neustart nach erfolgreichem Systemupdate"
|
||||||
|
|
||||||
else
|
else
|
||||||
log ""
|
# Kein automatischer Host-Neustart: notwendige Gast-Neustarts jetzt
|
||||||
log "Host-Neustart erforderlich, aber automatischer Neustart wird NICHT ausgeführt."
|
# einzeln ausführen. Das gilt auch bei --no-reboot oder wenn der
|
||||||
log "Grund: $ERRORS Fehler im Update-Lauf."
|
# automatische Host-Neustart in der Konfiguration deaktiviert ist.
|
||||||
|
reboot_pending_guests
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user