bootstrap: feat: Add apt update script that checks last run time

This commit is contained in:
PorridgePi
2022-10-01 18:18:06 +01:00
parent a507be1a51
commit ae3901c6f0

View File

@@ -0,0 +1,10 @@
lastAptUpdateSeconds=$(date +%s -r /var/cache/apt/pkgcache.bin)
currentSeconds=$(date +%s)
diffSeconds=$(($currentSeconds - $lastAptUpdateSeconds))
echo "apt update was last run $diffSeconds second(s) ago"
# Run apt update if it has not been run for more than 30 minutes
if [[ "$diffSeconds" -gt 1800 ]]; then
echo 'Running apt update...'
sudo apt update
fi