From 120e06948438c93c58fea5225a8f7efedf616120 Mon Sep 17 00:00:00 2001 From: flatsiedatsie Date: Sun, 21 Aug 2022 22:38:34 +0200 Subject: [PATCH] test if enough disk space for fresh backup --- install_candle_controller.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/install_candle_controller.sh b/install_candle_controller.sh index 92ed70b..61ab908 100644 --- a/install_candle_controller.sh +++ b/install_candle_controller.sh @@ -168,20 +168,25 @@ echo # Create a backup first -if [ -f /home/pi/webthings/gateway/build/app.js ] \ -&& [ -f /home/pi/webthings/gateway/build/static/index.html ] \ -&& [ -d /home/pi/webthings/gateway/node_modules ] \ -&& [ -d /home/pi/webthings/gateway/build/static/bundle ]; + +availMem=$(df -P "/dev/mmcblk0p2" | awk 'END{print $4}') +if [ "$availMem" -gt "200000" ]; then - echo "Detected old webthings directory! Creating aditional backup" - echo "Candle: Detected old webthings directory. Creating additional backup" | sudo tee -a /dev/kmsg - echo "Candle: Detected old webthings directory. Creating additional backup" | sudo tee -a /boot/candle_log.txt - #mv /home/pi/webthings /home/pi/webthings-old - tar -czf ./controller_backup_fresh.tar ./webthings + if [ -f /home/pi/webthings/gateway/build/app.js ] \ + && [ -f /home/pi/webthings/gateway/build/static/index.html ] \ + && [ -f /home/pi/webthings/gateway/.post_upgrade_complete ] \ + && [ -d /home/pi/webthings/gateway/node_modules ] \ + && [ -d /home/pi/webthings/gateway/build/static/bundle ]; + then + echo "Detected old webthings directory! Creating aditional backup" + echo "Candle: Detected old webthings directory. Creating additional backup" | sudo tee -a /dev/kmsg + echo "Candle: Detected old webthings directory. Creating additional backup" | sudo tee -a /boot/candle_log.txt + #mv /home/pi/webthings /home/pi/webthings-old + tar -czf ./controller_backup_fresh.tar ./webthings + fi fi - #rm -rf /home/pi/webthings echo "Candle: Starting controller source code download" | sudo tee -a /dev/kmsg