OFFLINE_TOKEN=$( echo "${OFFLINE_TOKEN}" | tr -d '[:space:]' )
+DATE_LAST_TOKEN='2024-05-30 10:00:00+02:00'
+MAX_DAYS_LAST_TOKEN="29"
+RED_HAT_DOWNLOAD_USER="dpx-downloader"
+
declare -A IMAGE_CHECKSUMS=()
IMAGE_CHECKSUMS['rhel-7.9-dvd']='2cb36122a74be084c551bc7173d2d38a1cfb75c8ffbc1489c630c916d1b31b25'
}
+#------------------------------------------------------------------------------
+check_token_age() {
+
+ empty_line
+ debug "Checking age of access token ..."
+
+ local last_token_ts=
+ local current_ts=
+ local cur_time_diff=
+ local max_time_diff=
+
+ last_token_ts=$( date -d "${DATE_LAST_TOKEN}" +'%s' )
+ current_ts=$( date +'%s' )
+ cur_time_diff=$(( current_ts - last_token_ts ))
+ max_time_diff=$(( MAX_DAYS_LAST_TOKEN * 24 * 60 * 60 ))
+
+ debug "The date of getting the access token is ${CYAN}${cur_time_diff} seconds ago${NORMAL}."
+
+ if [[ "${cur_time_diff}" -gt "${max_time_diff}" ]] ; then
+ local msg="The current ${RED}access token is too old${NORMAL} - "
+ msg+="it is from ${CYAN}${DATE_LAST_TOKEN}${NORMAL}. "
+ msg+="It may be at most ${CYAN}${MAX_DAYS_LAST_TOKEN} days${NORMAL} old."
+ error "${msg}"
+
+ empty_line
+ msg="Please log in at Red Hat Customer portal as '${CYAN}${RED_HAT_DOWNLOAD_USER}${NORMAL}', "
+ msg+="get a new access token and update the token and the date of the last change in this script."
+ error "${msg}"
+ empty_line
+
+ exit 6
+ fi
+
+}
+
+
#------------------------------------------------------------------------------
get_access_token() {
get_options "$@"
set_locale "en_US.utf8"
+ check_token_age
get_access_token
get_image_info
download_image