From 6bbae71eb9915148293d5e56164a3f4a96c146d8 Mon Sep 17 00:00:00 2001 From: Joe Prochazka Date: Thu, 21 Jun 2018 12:31:04 -0400 Subject: [PATCH] Added a way to force apt update. --- bash/init.sh | 5 +++-- install.sh | 13 ++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bash/init.sh b/bash/init.sh index c1fa7ad..f2dc8a4 100755 --- a/bash/init.sh +++ b/bash/init.sh @@ -178,12 +178,13 @@ function UpdateOperatingSystem() { ## Update the repository packages and check that prerequisite packages are installed. -# Only call AptUpdate if last update was more than ${APT_UPDATE_THRESHOLD} seconds ago. +# Only call AptUpdate if last update was more than ${APT_UPDATE_THRESHOLD} seconds ago or if the user forced the update. 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 + +if [[ "${APT_UPDATE_DELTA}" -gt "${APT_UPDATE_THRESHOLD}" ]] || [[ "${RECEIVER_FORCE_APT_UPDATE}" = "true" ]] ; then AptUpdate fi diff --git a/install.sh b/install.sh index 39e710d..9c217d3 100755 --- a/install.sh +++ b/install.sh @@ -66,6 +66,7 @@ function DisplayHelp() { echo "-h --help Shows this message." echo "-l --log-output Logs all output to a file in the logs directory." echo "-m --mta= Specify which email MTA to use currently Exim or Postfix." + echo "-u --apt-update Forces the apt update command to be ran." echo "-v --verbose Provides extra confirmation at each stage of the install." echo "" } @@ -123,7 +124,7 @@ while [[ $# -gt 0 ]] ; do fi shift 2 ;; - --mta*) + --mta*) MTA=`echo ${1^^} | sed -e 's/^[^=]*=//g'` if [ $MTA != "EXIM" ] && [ $MTA != "POSTFIX" ]; then echo "MTA can only be either EXIM or POSTFIX." @@ -131,7 +132,11 @@ while [[ $# -gt 0 ]] ; do fi shift 1 ;; - + -u|--apt-update) + # Force apt update. + FORCE_APT_UPDATE="true" + shift 1 + ;; -v|--verbose) # Provides extra confirmation at each stage of the install. VERBOSE="true" @@ -164,8 +169,9 @@ fi export RECEIVER_AUTOMATED_INSTALL=${AUTOMATED_INSTALL} export RECEIVER_PROJECT_BRANCH=${PROJECT_BRANCH} export RECEIVER_CONFIGURATION_FILE=${CONFIGURATION_FILE} -export RECEIVER_VERBOSE=${VERBOSE} export RECEIVER_MTA=${MTA} +export RECEIVER_FORCE_APT_UPDATE=$FORCE_APT_UPDATE +export RECEIVER_VERBOSE=${VERBOSE} ## EXECUTE BASH/INIT.SH @@ -197,6 +203,7 @@ unset RECEIVER_BUILD_DIRECTORY unset RECEIVER_PROJECT_BRANCH unset RECEIVER_AUTOMATED_INSTALL unset RECEIVER_CONFIGURATION_FILE +unset RECEIVER_FORCE_APT_UPDATE unset RECEIVER_VERBOSE unset RECEIVER_PROJECT_TITLE unset RECEIVER_MTA