QUIET='n'
SIMULATE="n"
-VERSION="0.3.3"
+VERSION="0.3.4"
BASE_NAME="$(basename ${0})"
BASE_DIR="$(dirname ${0})"
MOUNTPOINT=
IMAGE_ROOT="/var/www/cobbler/ks_mirror"
IMAGE_DIR="${IMAGE_ROOT}/CentOS-8-Stream-${ARCH}"
+TIMESTAMP_FILE="${IMAGE_DIR}.timestamp"
TMP_IMAGE_DIR=
LAST_TSTAMP="0"
LOGFILE=
trap - INT TERM EXIT ABRT
cleanup_image
+ info "Writing current timestamp '${CYAN}${tstamp}${NORMAL}' into '${CYAN}${TIMESTAMP_FILE}${NORMAL}' ..."
+ if [[ "${SIMULATE}" != "y" ]] ; then
+ echo "${tstamp}" > "${TIMESTAMP_FILE}"
+ fi
+
return ${ret}
}
len="${#URLS[*]}"
index=$(( ${RANDOM} % ${len} ))
base_url="${URLS[${index}]}"
+ line
info "Trying '${CYAN}${base_url}${NORMAL}' ..."
- empty_line
if perform_mirror "${base_url}" ; then
return 0
fi
- sleep 1
+ if [[ "${len}" == 1 ]] ; then
+ break
+ fi
+ empty_line
+ sleep 0.5
create_urls "${base_url}"
done
}
+#------------------------------------------------------------------------------
+get_current_timestamp() {
+
+ info "Get timestamp of last update from '${CYAN}${TIMESTAMP_FILE}${NORMAL}' ..."
+
+ if [[ ! -e "${TIMESTAMP_FILE}" ]] ; then
+ debug "File '${CYAN}${TIMESTAMP_FILE}${NORMAL}' does not exists."
+ return
+ fi
+
+ if [[ ! -f "${TIMESTAMP_FILE}" ]] ; then
+ warn "File '${CYAN}${TIMESTAMP_FILE}${NORMAL}' exists, but is not a regular file."
+ return
+ fi
+
+ local first_line=$( cat "${TIMESTAMP_FILE}" | \
+ grep -v -E '^[ ]*(#.*)?$' | \
+ head -n 1 | \
+ sed -e 's/^[ ]*//' -e 's/[ ]$//' )
+ debug "First line: ${first_line}"
+ LAST_TSTAMP=$(( ${first_line} + 0 ))
+ info "Last Timestamp: '${CYAN}${LAST_TSTAMP}${NORMAL}'."
+
+}
+
#------------------------------------------------------------------------------
main() {
info "Starting update of boot environment of '${GREEN}CentOS-8 Stream${NORMAL}'."
empty_line
+ get_current_timestamp
+ empty_line
do_update
+ empty_line
info "Finished."
}