From d2ea3d0e3c69c7ccf5bb7a79963dc4aaadb97cf1 Mon Sep 17 00:00:00 2001 From: romeo-golf Date: Sat, 14 Jan 2017 05:03:06 +0000 Subject: [PATCH] Only call AptUpdate if last update was more than seconds ago, currently set to 1800 --- bash/init.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bash/init.sh b/bash/init.sh index 8d20631..5b5cb2d 100755 --- a/bash/init.sh +++ b/bash/init.sh @@ -177,7 +177,15 @@ function UpdateOperatingSystem() { ## Update the repository packages and check that prerequisite packages are installed. -AptUpdate +# Only call AptUpdate if last update was more than $APT_UPDATE_THRESHOLD seconds ago. +APT_UPDATE_THRESHOLD="1800" +APT_UPDATE_CURRENT_EPOCH=`date +%s` +APT_UPDATE_LAST_EPOCH=`stat -c %Y /var/cache/apt/pkgcache.bin` +APT_UPDATE_DELTA=`echo $[${APT_UPDATE_CURRENT_EPOCH} - ${APT_UPDATE_LAST_EPOCH}]` +if [[ "${APT_UPDATE_DELTA}" -gt "${APT_UPDATE_THRESHOLD}" ]] ; then + AptUpdate +fi + CheckPrerequisites ## DISPLAY WELCOME SCREEN