Skip to content

Commit d8ba49d

Browse files
committed
fix(system): read df's available column from the end in do-update-lxc.sh
Same fix as in perform_update.sh: df puts a device name that does not fit on a line of its own, and $4 of line 2 is then part of the name instead of the free space. An LXC update would have refused to run with "Not enough free space" on a filesystem with plenty of it. The remaining df readers are fine: init.sh and resources.sh ask for a single column with --output=, which cannot wrap. Signed-off-by: Simon Walz <contact@simonwalz.de>
1 parent 891a0bb commit d8ba49d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎system/cuos/do-update-lxc.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ if [[ "${IMAGE_VERSION_STRING}" == "$(cat /etc/image)" ]]; then
3030
raise_info 22 "No new image version available. Exiting."
3131
fi
3232

33-
AVAIL_BYTES=$(df -B1 "/" | awk 'NR==2 {print $4}')
33+
# Fields counted from the end: df puts a device name that does not fit on a
34+
# line of its own, and then the columns are one line further down.
35+
AVAIL_BYTES=$(df -B1 "/" | awk 'END { print $(NF-2) }')
3436
REQUIRED_BYTES=$((2 * 1024 * 1024 * 1024))
3537
if [ "$AVAIL_BYTES" -le "$REQUIRED_BYTES" ]; then
3638
report_info "cuos:update:no_space" "Not enough free disk space available"

0 commit comments

Comments
 (0)