From 736edf44e4bf89e2e7f57e4c062453aa5af0fcac Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 24 Jan 2016 17:53:27 +0000 Subject: [PATCH] Added date check before running apt-get update/upgrade. Wont run apt-get update/upgrade if it has already been run today --- automated install/basic-install.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a42241d4..84d8f950 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -296,14 +296,24 @@ stopServices(){ checkForDependencies(){ - echo ":::" - #update package lists - echo -n "::: Updating package list before install...." - $SUDO apt-get -qq update > /dev/null & spinner $! - echo " done!" - echo -n "::: Upgrading installed apt-get packages...." - $SUDO apt-get -y -qq upgrade > /dev/null & spinner $! - echo " done!" + echo ":::" + #Check to see if apt-get update has already been run today + timestamp=$(stat -c %Y /var/cache/apt/) + timestampAsDate=$(date -d @$timestamp "+%b %e") + today=$(date "+%b %e") + + if [ ! "$today" == "$timestampAsDate" ]; then + #update package lists + echo -n "::: Updating package list before install...." + $SUDO apt-get -qq update > /dev/null & spinner $! + echo " done!" + echo -n "::: Upgrading installed apt-get packages...." + $SUDO apt-get -y -qq upgrade > /dev/null & spinner $! + echo " done!" + else + echo "::: Apt-get update already run today, any more would be overkill..." + fi + echo ":::" echo "::: Checking dependencies:"