This commit is contained in:
sharky committed 2026-10-04 17:26:58 +02:00
1 parent a4ccbd2e34
commit 5b43921550
1 file changed
+37 -1
+37 -1
View File
@@ -31,6 +31,7 @@ ONLY_VM=""
NO_REBOOT="no"
ERRORS=0
ERROR_DETAILS=()
HOST_OK="not-run"
HOST_REBOOT_REQUIRED="no"
HOST_REBOOT_SCHEDULED="no"
@@ -71,6 +72,12 @@ log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
}
add_error() {
local detail="$1"
ERROR_DETAILS+=("$detail")
}
ensure_notification_setup() {
[[ "$NOTIFY_ENABLED" == "yes" ]] || return 0
@@ -147,7 +154,17 @@ send_update_notification() {
title="Proxmox Updater - $status"
fi
message="Proxmox Guest Updater
local error_details_text="Keine"
if (( ${#ERROR_DETAILS[@]} > 0 )); then
error_details_text=""
local error_detail
for error_detail in "${ERROR_DETAILS[@]}"; do
error_details_text+="- ${error_detail}"$'\n'
done
error_details_text="${error_details_text%$'\n'}"
fi
message="Proxmox Guest Updater
Host: $(hostname)
Zeit: $(date '+%d.%m.%Y %H:%M:%S')
@@ -170,6 +187,9 @@ VM:
Fehler gesamt: $ERRORS
Fehlerdetails:
$error_details_text
Neustarts:
$MAIL_STATUS_DETAIL
@@ -498,6 +518,7 @@ check_lxc() {
if ! pct exec "$id" -- bash -lc 'apt-get update'; then
log "CT $id ($name): apt-get update FEHLER."
add_error "CT $id ($name): apt-get update fehlgeschlagen"
LXC_FAILED=$((LXC_FAILED + 1))
ERRORS=$((ERRORS + 1))
return
@@ -571,6 +592,7 @@ update_lxc() {
if ! pct exec "$id" -- bash -lc 'apt-get update'; then
log "CT $id ($name): apt-get update FEHLER."
add_error "CT $id ($name): apt-get update fehlgeschlagen"
LXC_FAILED=$((LXC_FAILED + 1))
ERRORS=$((ERRORS + 1))
@@ -589,6 +611,7 @@ update_lxc() {
if ! simulation="$(pct exec "$id" -- bash -lc 'LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get -s full-upgrade' 2>&1)"; then
printf '%s\n' "$simulation"
log "CT $id ($name): full-upgrade Simulation FEHLER."
add_error "CT $id ($name): full-upgrade Simulation fehlgeschlagen"
LXC_FAILED=$((LXC_FAILED + 1))
ERRORS=$((ERRORS + 1))
@@ -604,6 +627,7 @@ update_lxc() {
if [[ -z "$upgraded" || -z "$installed" || -z "$removed" ]]; then
log "CT $id ($name): Simulation konnte nicht ausgewertet werden."
add_error "CT $id ($name): full-upgrade Simulation konnte nicht ausgewertet werden"
LXC_FAILED=$((LXC_FAILED + 1))
ERRORS=$((ERRORS + 1))
if [[ "$started_by_us" == "yes" ]]; then
@@ -622,6 +646,7 @@ update_lxc() {
'DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" full-upgrade'
then
log "CT $id ($name): full-upgrade FEHLER."
add_error "CT $id ($name): full-upgrade fehlgeschlagen"
LXC_FAILED=$((LXC_FAILED + 1))
ERRORS=$((ERRORS + 1))
@@ -886,6 +911,7 @@ update_vm() {
if ! vm_exec "$id" 'apt-get update'; then
log "VM $id ($name): apt-get update FEHLER."
add_error "VM $id ($name): apt-get update fehlgeschlagen"
VM_FAILED=$((VM_FAILED + 1))
ERRORS=$((ERRORS + 1))
@@ -909,6 +935,7 @@ update_vm() {
if (( sim_rc != 0 )) || ! printf '%s\n' "$simulation" | grep -Eq '"exitcode"[[:space:]]*:[[:space:]]*0'; then
printf '%s\n' "$simulation"
log "VM $id ($name): full-upgrade Simulation FEHLER."
add_error "VM $id ($name): full-upgrade Simulation fehlgeschlagen"
VM_FAILED=$((VM_FAILED + 1))
ERRORS=$((ERRORS + 1))
if [[ "$started_by_us" == "yes" ]]; then
@@ -924,6 +951,7 @@ update_vm() {
if [[ -z "$upgraded" || -z "$installed" || -z "$removed" ]]; then
printf '%s\n' "$simulation"
log "VM $id ($name): Simulation konnte nicht ausgewertet werden."
add_error "VM $id ($name): full-upgrade Simulation konnte nicht ausgewertet werden"
VM_FAILED=$((VM_FAILED + 1))
ERRORS=$((ERRORS + 1))
if [[ "$started_by_us" == "yes" ]]; then
@@ -942,6 +970,7 @@ update_vm() {
'DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" full-upgrade'
then
log "VM $id ($name): full-upgrade FEHLER."
add_error "VM $id ($name): full-upgrade fehlgeschlagen"
VM_FAILED=$((VM_FAILED + 1))
ERRORS=$((ERRORS + 1))
@@ -1147,6 +1176,13 @@ else
fi
log ""
log "Fehler gesamt: $ERRORS"
if (( ${#ERROR_DETAILS[@]} > 0 )); then
log ""
log "Fehlerdetails:"
for error_detail in "${ERROR_DETAILS[@]}"; do
log "- $error_detail"
done
fi
log "Host Update: $HOST_OK"
log "Host Reboot nötig: $HOST_REBOOT_REQUIRED"
log "============================================================"