V16
This commit is contained in:
1 parent
5b43921550
commit
57903725c1
1 file changed
+80
-15
+80
-15
@@ -32,6 +32,7 @@ NO_REBOOT="no"
|
|||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
ERROR_DETAILS=()
|
ERROR_DETAILS=()
|
||||||
|
FULL_UPGRADE_HINTS=()
|
||||||
HOST_OK="not-run"
|
HOST_OK="not-run"
|
||||||
HOST_REBOOT_REQUIRED="no"
|
HOST_REBOOT_REQUIRED="no"
|
||||||
HOST_REBOOT_SCHEDULED="no"
|
HOST_REBOOT_SCHEDULED="no"
|
||||||
@@ -131,6 +132,46 @@ EOF
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
add_full_upgrade_hint() {
|
||||||
|
local guest="$1" summary="$2" packages="$3"
|
||||||
|
local detail="$guest: $summary"
|
||||||
|
[[ -n "$packages" ]] && detail+=" | Pakete: $packages"
|
||||||
|
FULL_UPGRADE_HINTS+=("$detail")
|
||||||
|
}
|
||||||
|
|
||||||
|
check_lxc_full_upgrade_hint() {
|
||||||
|
local id="$1" name="$2" output summary packages
|
||||||
|
output="$(pct exec "$id" -- bash -lc 'LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get -s full-upgrade' 2>/dev/null)" || return 0
|
||||||
|
summary="$(printf '%s\n' "$output" | grep -E '^[0-9]+ upgraded, [0-9]+ newly installed, [0-9]+ to remove' | tail -n1)"
|
||||||
|
[[ -n "$summary" ]] || return 0
|
||||||
|
printf '%s\n' "$summary" | grep -Eq '^0 upgraded, 0 newly installed, 0 to remove' && return 0
|
||||||
|
packages="$(printf '%s\n' "$output" | sed -nE 's/^(Inst|Remv) ([^ ]+).*/\2/p' | sort -u | paste -sd ',' -)"
|
||||||
|
packages="${packages//,/, }"
|
||||||
|
add_full_upgrade_hint "CT $id ($name)" "$summary" "$packages"
|
||||||
|
log "CT $id ($name): Hinweis - manuelle full-upgrade-Prüfung empfohlen."
|
||||||
|
}
|
||||||
|
|
||||||
|
check_vm_full_upgrade_hint() {
|
||||||
|
local id="$1" name="$2" output guest_rc payload summary packages
|
||||||
|
output="$(qm guest exec "$id" -- bash -lc '
|
||||||
|
out="$(LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get -s full-upgrade 2>/dev/null)" || exit 1
|
||||||
|
summary="$(printf "%s\n" "$out" | grep -E "^[0-9]+ upgraded, [0-9]+ newly installed, [0-9]+ to remove" | tail -n1)"
|
||||||
|
packages="$(printf "%s\n" "$out" | sed -nE "s/^(Inst|Remv) ([^ ]+).*/\2/p" | sort -u | paste -sd "," -)"
|
||||||
|
printf "SUMMARY=%s\nPACKAGES=%s\n" "$summary" "$packages"
|
||||||
|
' 2>&1)" || return 0
|
||||||
|
guest_rc="$(printf '%s\n' "$output" | sed -nE 's/^[[:space:]]*"exitcode"[[:space:]]*:[[:space:]]*([0-9]+),?.*/\1/p' | head -n1)"
|
||||||
|
[[ "$guest_rc" == "0" ]] || return 0
|
||||||
|
payload="$(printf '%s\n' "$output" | sed -nE 's/.*"out-data"[[:space:]]*:[[:space:]]*"(.*)".*/\1/p' | head -n1)"
|
||||||
|
summary="$(printf '%s' "$payload" | sed -nE 's/.*SUMMARY=([^\\]*).*/\1/p')"
|
||||||
|
packages="$(printf '%s' "$payload" | sed -nE 's/.*PACKAGES=([^\\"]*).*/\1/p')"
|
||||||
|
[[ -n "$summary" ]] || return 0
|
||||||
|
printf '%s\n' "$summary" | grep -Eq '^0 upgraded, 0 newly installed, 0 to remove' && return 0
|
||||||
|
packages="${packages//,/, }"
|
||||||
|
add_full_upgrade_hint "VM $id ($name)" "$summary" "$packages"
|
||||||
|
log "VM $id ($name): Hinweis - manuelle full-upgrade-Prüfung empfohlen."
|
||||||
|
}
|
||||||
|
|
||||||
send_update_notification() {
|
send_update_notification() {
|
||||||
[[ "$NOTIFY_ENABLED" == "yes" ]] || return 0
|
[[ "$NOTIFY_ENABLED" == "yes" ]] || return 0
|
||||||
|
|
||||||
@@ -154,7 +195,17 @@ send_update_notification() {
|
|||||||
title="Proxmox Updater - $status"
|
title="Proxmox Updater - $status"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local error_details_text="Keine"
|
local full_upgrade_text="Keine"
|
||||||
|
if (( ${#FULL_UPGRADE_HINTS[@]} > 0 )); then
|
||||||
|
full_upgrade_text=""
|
||||||
|
local full_upgrade_hint
|
||||||
|
for full_upgrade_hint in "${FULL_UPGRADE_HINTS[@]}"; do
|
||||||
|
full_upgrade_text+="- ${full_upgrade_hint}"$'\n'
|
||||||
|
done
|
||||||
|
full_upgrade_text="${full_upgrade_text%$'\n'}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local error_details_text="Keine"
|
||||||
if (( ${#ERROR_DETAILS[@]} > 0 )); then
|
if (( ${#ERROR_DETAILS[@]} > 0 )); then
|
||||||
error_details_text=""
|
error_details_text=""
|
||||||
local error_detail
|
local error_detail
|
||||||
@@ -187,6 +238,9 @@ VM:
|
|||||||
|
|
||||||
Fehler gesamt: $ERRORS
|
Fehler gesamt: $ERRORS
|
||||||
|
|
||||||
|
Full-upgrade-Prüfung empfohlen:
|
||||||
|
$full_upgrade_text
|
||||||
|
|
||||||
Fehlerdetails:
|
Fehlerdetails:
|
||||||
$error_details_text
|
$error_details_text
|
||||||
|
|
||||||
@@ -608,10 +662,10 @@ update_lxc() {
|
|||||||
local installed=0
|
local installed=0
|
||||||
local removed=0
|
local removed=0
|
||||||
|
|
||||||
if ! simulation="$(pct exec "$id" -- bash -lc 'LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get -s full-upgrade' 2>&1)"; then
|
if ! simulation="$(pct exec "$id" -- bash -lc 'LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get -s upgrade' 2>&1)"; then
|
||||||
printf '%s\n' "$simulation"
|
printf '%s\n' "$simulation"
|
||||||
log "CT $id ($name): full-upgrade Simulation FEHLER."
|
log "CT $id ($name): upgrade Simulation FEHLER."
|
||||||
add_error "CT $id ($name): full-upgrade Simulation fehlgeschlagen"
|
add_error "CT $id ($name): upgrade Simulation fehlgeschlagen"
|
||||||
LXC_FAILED=$((LXC_FAILED + 1))
|
LXC_FAILED=$((LXC_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 1))
|
ERRORS=$((ERRORS + 1))
|
||||||
|
|
||||||
@@ -627,7 +681,7 @@ update_lxc() {
|
|||||||
|
|
||||||
if [[ -z "$upgraded" || -z "$installed" || -z "$removed" ]]; then
|
if [[ -z "$upgraded" || -z "$installed" || -z "$removed" ]]; then
|
||||||
log "CT $id ($name): Simulation konnte nicht ausgewertet werden."
|
log "CT $id ($name): Simulation konnte nicht ausgewertet werden."
|
||||||
add_error "CT $id ($name): full-upgrade Simulation konnte nicht ausgewertet werden"
|
add_error "CT $id ($name): upgrade Simulation konnte nicht ausgewertet werden"
|
||||||
LXC_FAILED=$((LXC_FAILED + 1))
|
LXC_FAILED=$((LXC_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 1))
|
ERRORS=$((ERRORS + 1))
|
||||||
if [[ "$started_by_us" == "yes" ]]; then
|
if [[ "$started_by_us" == "yes" ]]; then
|
||||||
@@ -643,10 +697,10 @@ update_lxc() {
|
|||||||
log "CT $id ($name): $upgraded Upgrade(s), $installed Neuinstallation(en), $removed Entfernung(en)."
|
log "CT $id ($name): $upgraded Upgrade(s), $installed Neuinstallation(en), $removed Entfernung(en)."
|
||||||
|
|
||||||
if ! pct exec "$id" -- bash -lc \
|
if ! pct exec "$id" -- bash -lc \
|
||||||
'DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" full-upgrade'
|
'DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade'
|
||||||
then
|
then
|
||||||
log "CT $id ($name): full-upgrade FEHLER."
|
log "CT $id ($name): upgrade FEHLER."
|
||||||
add_error "CT $id ($name): full-upgrade fehlgeschlagen"
|
add_error "CT $id ($name): upgrade fehlgeschlagen"
|
||||||
LXC_FAILED=$((LXC_FAILED + 1))
|
LXC_FAILED=$((LXC_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 1))
|
ERRORS=$((ERRORS + 1))
|
||||||
|
|
||||||
@@ -666,6 +720,8 @@ update_lxc() {
|
|||||||
LXC_OK=$((LXC_OK + 1))
|
LXC_OK=$((LXC_OK + 1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
check_lxc_full_upgrade_hint "$id" "$name"
|
||||||
|
|
||||||
if [[ "$started_by_us" == "yes" ]]; then
|
if [[ "$started_by_us" == "yes" ]]; then
|
||||||
log "CT $id ($name): war vorher gestoppt -> wird wieder heruntergefahren."
|
log "CT $id ($name): war vorher gestoppt -> wird wieder heruntergefahren."
|
||||||
if ! pct shutdown "$id" --timeout 60; then
|
if ! pct shutdown "$id" --timeout 60; then
|
||||||
@@ -929,13 +985,13 @@ update_vm() {
|
|||||||
local removed=0
|
local removed=0
|
||||||
|
|
||||||
simulation="$(qm guest exec "$id" -- bash -lc \
|
simulation="$(qm guest exec "$id" -- bash -lc \
|
||||||
'LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get -s full-upgrade | tail -n1' 2>&1)"
|
'LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get -s upgrade | tail -n1' 2>&1)"
|
||||||
sim_rc=$?
|
sim_rc=$?
|
||||||
|
|
||||||
if (( sim_rc != 0 )) || ! printf '%s\n' "$simulation" | grep -Eq '"exitcode"[[:space:]]*:[[:space:]]*0'; then
|
if (( sim_rc != 0 )) || ! printf '%s\n' "$simulation" | grep -Eq '"exitcode"[[:space:]]*:[[:space:]]*0'; then
|
||||||
printf '%s\n' "$simulation"
|
printf '%s\n' "$simulation"
|
||||||
log "VM $id ($name): full-upgrade Simulation FEHLER."
|
log "VM $id ($name): upgrade Simulation FEHLER."
|
||||||
add_error "VM $id ($name): full-upgrade Simulation fehlgeschlagen"
|
add_error "VM $id ($name): upgrade Simulation fehlgeschlagen"
|
||||||
VM_FAILED=$((VM_FAILED + 1))
|
VM_FAILED=$((VM_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 1))
|
ERRORS=$((ERRORS + 1))
|
||||||
if [[ "$started_by_us" == "yes" ]]; then
|
if [[ "$started_by_us" == "yes" ]]; then
|
||||||
@@ -951,7 +1007,7 @@ update_vm() {
|
|||||||
if [[ -z "$upgraded" || -z "$installed" || -z "$removed" ]]; then
|
if [[ -z "$upgraded" || -z "$installed" || -z "$removed" ]]; then
|
||||||
printf '%s\n' "$simulation"
|
printf '%s\n' "$simulation"
|
||||||
log "VM $id ($name): Simulation konnte nicht ausgewertet werden."
|
log "VM $id ($name): Simulation konnte nicht ausgewertet werden."
|
||||||
add_error "VM $id ($name): full-upgrade Simulation konnte nicht ausgewertet werden"
|
add_error "VM $id ($name): upgrade Simulation konnte nicht ausgewertet werden"
|
||||||
VM_FAILED=$((VM_FAILED + 1))
|
VM_FAILED=$((VM_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 1))
|
ERRORS=$((ERRORS + 1))
|
||||||
if [[ "$started_by_us" == "yes" ]]; then
|
if [[ "$started_by_us" == "yes" ]]; then
|
||||||
@@ -967,10 +1023,10 @@ update_vm() {
|
|||||||
log "VM $id ($name): $upgraded Upgrade(s), $installed Neuinstallation(en), $removed Entfernung(en)."
|
log "VM $id ($name): $upgraded Upgrade(s), $installed Neuinstallation(en), $removed Entfernung(en)."
|
||||||
|
|
||||||
if ! vm_exec "$id" \
|
if ! vm_exec "$id" \
|
||||||
'DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" full-upgrade'
|
'DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade'
|
||||||
then
|
then
|
||||||
log "VM $id ($name): full-upgrade FEHLER."
|
log "VM $id ($name): upgrade FEHLER."
|
||||||
add_error "VM $id ($name): full-upgrade fehlgeschlagen"
|
add_error "VM $id ($name): upgrade fehlgeschlagen"
|
||||||
VM_FAILED=$((VM_FAILED + 1))
|
VM_FAILED=$((VM_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 1))
|
ERRORS=$((ERRORS + 1))
|
||||||
|
|
||||||
@@ -990,6 +1046,8 @@ update_vm() {
|
|||||||
VM_OK=$((VM_OK + 1))
|
VM_OK=$((VM_OK + 1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
check_vm_full_upgrade_hint "$id" "$name"
|
||||||
|
|
||||||
if [[ "$started_by_us" == "yes" ]]; then
|
if [[ "$started_by_us" == "yes" ]]; then
|
||||||
log "VM $id ($name): war vorher gestoppt -> wird wieder heruntergefahren."
|
log "VM $id ($name): war vorher gestoppt -> wird wieder heruntergefahren."
|
||||||
if ! qm shutdown "$id" --timeout 60; then
|
if ! qm shutdown "$id" --timeout 60; then
|
||||||
@@ -1176,6 +1234,13 @@ else
|
|||||||
fi
|
fi
|
||||||
log ""
|
log ""
|
||||||
log "Fehler gesamt: $ERRORS"
|
log "Fehler gesamt: $ERRORS"
|
||||||
|
if (( ${#FULL_UPGRADE_HINTS[@]} > 0 )); then
|
||||||
|
log ""
|
||||||
|
log "Full-upgrade-Prüfung empfohlen:"
|
||||||
|
for full_upgrade_hint in "${FULL_UPGRADE_HINTS[@]}"; do
|
||||||
|
log "- $full_upgrade_hint"
|
||||||
|
done
|
||||||
|
fi
|
||||||
if (( ${#ERROR_DETAILS[@]} > 0 )); then
|
if (( ${#ERROR_DETAILS[@]} > 0 )); then
|
||||||
log ""
|
log ""
|
||||||
log "Fehlerdetails:"
|
log "Fehlerdetails:"
|
||||||
|
|||||||
Reference in new issue
Block a user