From 103fecb133540f21da658187fb492c16f931f754 Mon Sep 17 00:00:00 2001 From: jumperfly Date: Sat, 19 Nov 2016 02:45:35 +0000 Subject: [PATCH] Remove old backup OS image before moving new OS image to reduce disk space requirements. --- src/init | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/init b/src/init index 49727e3..14b8ef6 100755 --- a/src/init +++ b/src/init @@ -42,6 +42,9 @@ if findfs $NEWIMG_DEVICE &> /dev/null; then # Mount device containing current image RW and replace with updated image echo "Detected a new OS image, copying to image partition..." mount -t ext4 $IMG_DEVICE /mnt/img + if [[ -e /mnt/img/$OS_IMAGE-old ]]; then + rm -f /mnt/img/$OS_IMAGE-old + fi mv -f /mnt/newimg/$OS_IMAGE /mnt/img/$OS_IMAGE-new mv -f /mnt/img/$OS_IMAGE /mnt/img/$OS_IMAGE-old mv /mnt/img/$OS_IMAGE-new /mnt/img/$OS_IMAGE