QUIET='n'
SIMULATE="n"
-VERSION="0.3.1"
+VERSION="0.3.2"
BASE_NAME="$(basename ${0})"
BASE_DIR="$(dirname ${0})"
ARCH="x86_64"
HAS_MOUNTED="n"
MOUNTPOINT_ROOT="/var/tmp/centos8-stream-${ARCH}"
+MOUNTPOINT=
IMAGE_ROOT="/var/www/cobbler/ks_mirror"
IMAGE_DIR="${IMAGE_ROOT}/CentOS-8-Stream-${ARCH}"
LAST_TSTAMP="0"
info "Cleaning up mounts and images"
+ if [[ -n "${MOUNTPOINT}" ]] ; then
+ if [[ "${HAS_MOUNTED}" == "y" ]] ; then
+ umount "${MOUNTPOINT}"
+ fi
+
+ if [[ -d "${MOUNTPOINT}" ]] ; then
+ purge -r "${MOUNTPOINT}"
+ fi
+ fi
+
if [[ -n "${ISO_IMAGE}" && -f "${ISO_IMAGE}" ]] ; then
purge "${ISO_IMAGE}"*
fi
}
+#------------------------------------------------------------------------------
+mount_image() {
+
+ MOUNTPOINT=$( mktemp --directory "${MOUNTPOINT_ROOT}/XXXXXXXX" )
+
+ info "Mounting '${CYAN}${ISO_IMAGE}${NORMAL}' => '${CYAN}${MOUNTPOINT}${NORMAL}' ..."
+ local cmd="mount -t iso9660 -o loop,ro \"${ISO_IMAGE}\" \"${MOUNTPOINT}\""
+ if [[ "${SIMULATE}" == "y" ]] ; then
+ info "Executing: ${cmd}"
+ return 0
+ fi
+ debug "Executing: ${cmd}"
+
+ if eval ${cmd} 2>&1 | tee -a "${LOGFILE}" ; then
+ debug "Mount successful:\n$( ls -lA "${MOUNTPOINT}" )"
+ HAS_MOUNTED="y"
+ return 0
+ fi
+
+ warn "Mounting '${YELLOW}${ISO_IMAGE}${NORMAL}' => '${YELLOW}${MOUNTPOINT}${NORMAL}' was not successful."
+ return 7
+
+}
+
#------------------------------------------------------------------------------
perform_mirror() {
return 1
fi
+ if mount_image ; then
+ :
+ else
+ trap - INT TERM EXIT ABRT
+ cleanup_image
+ return 1
+ fi
+
trap - INT TERM EXIT ABRT
cleanup_image