From 178e3ed57c29b9e9b2100212043f8e6ab4a50bc0 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 15 Jan 2024 14:45:44 +0100 Subject: [PATCH] pdist-bootcheck: Don't loop when system disk is full This script uses a file `/var/run/updatecheck.reboot-triggered` to prevent boot loops on pdist failures when pdist+reboot is required. However, when the system disk is full, the creation of that file might fail. Check for reasonable free space before attempting pdist and create the flag file before pdist is started. --- pdist/pdist-bootcheck | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pdist/pdist-bootcheck b/pdist/pdist-bootcheck index a2e7a49..a00eebb 100755 --- a/pdist/pdist-bootcheck +++ b/pdist/pdist-bootcheck @@ -35,10 +35,15 @@ elif [ "$need_pdist_and_reboot" ]; then rm /var/run/updatecheck.reboot-triggered exit 1 fi + if (( $(stat -f -c %f /) * $(stat -f -c %s /) /1024/1024/1024 < 10)); then + echo "Update and reboot required but prevented because of insufficient free disk space (<10G)" + exit 1 + fi echo "Update and reboot required" + touch /var/run/updatecheck.reboot-triggered + sync / while true; do sleep 5; echo "System update in progress. Please be patient..."; done & netcat $(distmaster) 237 mxgrub default - touch /var/run/updatecheck.reboot-triggered systemctl start reboot.target --job-mode=replace-irreversibly fi