Skip to content

Commit

Permalink
test if enough disk space for fresh backup
Browse files Browse the repository at this point in the history
  • Loading branch information
flatsiedatsie committed Aug 21, 2022
1 parent fc0dbb9 commit 120e069
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions install_candle_controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 120e069

Please sign in to comment.