V17
This commit is contained in:
1 parent
57903725c1
commit
1ddfb1233a
1 file changed
+30
-8
+30
-8
@@ -984,11 +984,23 @@ update_vm() {
|
|||||||
local installed=0
|
local installed=0
|
||||||
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 upgrade | tail -n1' 2>&1)"
|
out="$(LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get -s upgrade 2>&1)" || exit 10
|
||||||
|
summary="$(printf "%s\n" "$out" | grep -E "^[0-9]+ upgraded, [0-9]+ newly installed, [0-9]+ to remove" | tail -n1)"
|
||||||
|
[ -n "$summary" ] || exit 11
|
||||||
|
set -- $summary
|
||||||
|
upgraded="$1"
|
||||||
|
installed="$3"
|
||||||
|
removed="$6"
|
||||||
|
printf "APTCOUNTS=%s,%s,%s\n" "$upgraded" "$installed" "$removed"
|
||||||
|
if [ "$upgraded" -eq 0 ] && [ "$installed" -eq 0 ] && [ "$removed" -eq 0 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
exit 42
|
||||||
|
' 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 )); then
|
||||||
printf '%s\n' "$simulation"
|
printf '%s\n' "$simulation"
|
||||||
log "VM $id ($name): upgrade Simulation FEHLER."
|
log "VM $id ($name): upgrade Simulation FEHLER."
|
||||||
add_error "VM $id ($name): upgrade Simulation fehlgeschlagen"
|
add_error "VM $id ($name): upgrade Simulation fehlgeschlagen"
|
||||||
@@ -1000,13 +1012,21 @@ update_vm() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
upgraded="$(printf '%s\n' "$simulation" | sed -nE 's/.*out-data"[[:space:]]*:[[:space:]]*"([0-9]+) upgraded, ([0-9]+) newly installed, ([0-9]+) to remove.*/\1/p' | head -n1)"
|
guest_rc="$(
|
||||||
installed="$(printf '%s\n' "$simulation" | sed -nE 's/.*out-data"[[:space:]]*:[[:space:]]*"([0-9]+) upgraded, ([0-9]+) newly installed, ([0-9]+) to remove.*/\2/p' | head -n1)"
|
printf '%s\n' "$simulation" |
|
||||||
removed="$(printf '%s\n' "$simulation" | sed -nE 's/.*out-data"[[:space:]]*:[[:space:]]*"([0-9]+) upgraded, ([0-9]+) newly installed, ([0-9]+) to remove.*/\3/p' | head -n1)"
|
sed -nE 's/^[[:space:]]*"exitcode"[[:space:]]*:[[:space:]]*([0-9]+),?[[:space:]]*$/\1/p' |
|
||||||
|
head -n1
|
||||||
|
)"
|
||||||
|
|
||||||
if [[ -z "$upgraded" || -z "$installed" || -z "$removed" ]]; then
|
counts="$(
|
||||||
|
printf '%s\n' "$simulation" |
|
||||||
|
sed -nE 's/.*APTCOUNTS=([0-9]+),([0-9]+),([0-9]+).*/\1 \2 \3/p' |
|
||||||
|
head -n1
|
||||||
|
)"
|
||||||
|
|
||||||
|
if [[ -z "$guest_rc" || -z "$counts" || ( "$guest_rc" != "0" && "$guest_rc" != "42" ) ]]; then
|
||||||
printf '%s\n' "$simulation"
|
printf '%s\n' "$simulation"
|
||||||
log "VM $id ($name): Simulation konnte nicht ausgewertet werden."
|
log "VM $id ($name): upgrade Simulation konnte nicht ausgewertet werden."
|
||||||
add_error "VM $id ($name): 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))
|
||||||
@@ -1016,6 +1036,8 @@ update_vm() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
read -r upgraded installed removed <<< "$counts"
|
||||||
|
|
||||||
if (( upgraded == 0 && installed == 0 && removed == 0 )); then
|
if (( upgraded == 0 && installed == 0 && removed == 0 )); then
|
||||||
log "VM $id ($name): bereits aktuell."
|
log "VM $id ($name): bereits aktuell."
|
||||||
VM_CURRENT=$((VM_CURRENT + 1))
|
VM_CURRENT=$((VM_CURRENT + 1))
|
||||||
|
|||||||
Reference in new issue
Block a user