V15
This commit is contained in:
1 parent
a4ccbd2e34
commit
5b43921550
1 file changed
+36
+36
@@ -31,6 +31,7 @@ ONLY_VM=""
|
|||||||
NO_REBOOT="no"
|
NO_REBOOT="no"
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
|
ERROR_DETAILS=()
|
||||||
HOST_OK="not-run"
|
HOST_OK="not-run"
|
||||||
HOST_REBOOT_REQUIRED="no"
|
HOST_REBOOT_REQUIRED="no"
|
||||||
HOST_REBOOT_SCHEDULED="no"
|
HOST_REBOOT_SCHEDULED="no"
|
||||||
@@ -71,6 +72,12 @@ log() {
|
|||||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_error() {
|
||||||
|
local detail="$1"
|
||||||
|
ERROR_DETAILS+=("$detail")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ensure_notification_setup() {
|
ensure_notification_setup() {
|
||||||
[[ "$NOTIFY_ENABLED" == "yes" ]] || return 0
|
[[ "$NOTIFY_ENABLED" == "yes" ]] || return 0
|
||||||
|
|
||||||
@@ -147,6 +154,16 @@ send_update_notification() {
|
|||||||
title="Proxmox Updater - $status"
|
title="Proxmox Updater - $status"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
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
|
message="Proxmox Guest Updater
|
||||||
Host: $(hostname)
|
Host: $(hostname)
|
||||||
Zeit: $(date '+%d.%m.%Y %H:%M:%S')
|
Zeit: $(date '+%d.%m.%Y %H:%M:%S')
|
||||||
@@ -170,6 +187,9 @@ VM:
|
|||||||
|
|
||||||
Fehler gesamt: $ERRORS
|
Fehler gesamt: $ERRORS
|
||||||
|
|
||||||
|
Fehlerdetails:
|
||||||
|
$error_details_text
|
||||||
|
|
||||||
Neustarts:
|
Neustarts:
|
||||||
$MAIL_STATUS_DETAIL
|
$MAIL_STATUS_DETAIL
|
||||||
|
|
||||||
@@ -498,6 +518,7 @@ check_lxc() {
|
|||||||
|
|
||||||
if ! pct exec "$id" -- bash -lc 'apt-get update'; then
|
if ! pct exec "$id" -- bash -lc 'apt-get update'; then
|
||||||
log "CT $id ($name): apt-get update FEHLER."
|
log "CT $id ($name): apt-get update FEHLER."
|
||||||
|
add_error "CT $id ($name): apt-get update fehlgeschlagen"
|
||||||
LXC_FAILED=$((LXC_FAILED + 1))
|
LXC_FAILED=$((LXC_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 1))
|
ERRORS=$((ERRORS + 1))
|
||||||
return
|
return
|
||||||
@@ -571,6 +592,7 @@ update_lxc() {
|
|||||||
|
|
||||||
if ! pct exec "$id" -- bash -lc 'apt-get update'; then
|
if ! pct exec "$id" -- bash -lc 'apt-get update'; then
|
||||||
log "CT $id ($name): apt-get update FEHLER."
|
log "CT $id ($name): apt-get update FEHLER."
|
||||||
|
add_error "CT $id ($name): apt-get update fehlgeschlagen"
|
||||||
LXC_FAILED=$((LXC_FAILED + 1))
|
LXC_FAILED=$((LXC_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 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
|
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"
|
printf '%s\n' "$simulation"
|
||||||
log "CT $id ($name): full-upgrade Simulation FEHLER."
|
log "CT $id ($name): full-upgrade Simulation FEHLER."
|
||||||
|
add_error "CT $id ($name): full-upgrade Simulation fehlgeschlagen"
|
||||||
LXC_FAILED=$((LXC_FAILED + 1))
|
LXC_FAILED=$((LXC_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 1))
|
ERRORS=$((ERRORS + 1))
|
||||||
|
|
||||||
@@ -604,6 +627,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"
|
||||||
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
|
||||||
@@ -622,6 +646,7 @@ update_lxc() {
|
|||||||
'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" full-upgrade'
|
||||||
then
|
then
|
||||||
log "CT $id ($name): full-upgrade FEHLER."
|
log "CT $id ($name): full-upgrade FEHLER."
|
||||||
|
add_error "CT $id ($name): full-upgrade fehlgeschlagen"
|
||||||
LXC_FAILED=$((LXC_FAILED + 1))
|
LXC_FAILED=$((LXC_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 1))
|
ERRORS=$((ERRORS + 1))
|
||||||
|
|
||||||
@@ -886,6 +911,7 @@ update_vm() {
|
|||||||
|
|
||||||
if ! vm_exec "$id" 'apt-get update'; then
|
if ! vm_exec "$id" 'apt-get update'; then
|
||||||
log "VM $id ($name): apt-get update FEHLER."
|
log "VM $id ($name): apt-get update FEHLER."
|
||||||
|
add_error "VM $id ($name): apt-get update fehlgeschlagen"
|
||||||
VM_FAILED=$((VM_FAILED + 1))
|
VM_FAILED=$((VM_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 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
|
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): full-upgrade Simulation FEHLER."
|
||||||
|
add_error "VM $id ($name): full-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
|
||||||
@@ -924,6 +951,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"
|
||||||
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
|
||||||
@@ -942,6 +970,7 @@ update_vm() {
|
|||||||
'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" full-upgrade'
|
||||||
then
|
then
|
||||||
log "VM $id ($name): full-upgrade FEHLER."
|
log "VM $id ($name): full-upgrade FEHLER."
|
||||||
|
add_error "VM $id ($name): full-upgrade fehlgeschlagen"
|
||||||
VM_FAILED=$((VM_FAILED + 1))
|
VM_FAILED=$((VM_FAILED + 1))
|
||||||
ERRORS=$((ERRORS + 1))
|
ERRORS=$((ERRORS + 1))
|
||||||
|
|
||||||
@@ -1147,6 +1176,13 @@ else
|
|||||||
fi
|
fi
|
||||||
log ""
|
log ""
|
||||||
log "Fehler gesamt: $ERRORS"
|
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 Update: $HOST_OK"
|
||||||
log "Host Reboot nötig: $HOST_REBOOT_REQUIRED"
|
log "Host Reboot nötig: $HOST_REBOOT_REQUIRED"
|
||||||
log "============================================================"
|
log "============================================================"
|
||||||
|
|||||||
Reference in new issue
Block a user