]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Finishing scripts/get-rhel-dvd-iso-image
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 30 May 2024 10:04:01 +0000 (12:04 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 30 May 2024 10:04:01 +0000 (12:04 +0200)
scripts/get-rhel-dvd-iso-image

index fa9ca4ecdffa407b04ba3a265913dcb092eedb81..9111e9f4a1a4339f08f342c397a1b5c9f56dff4c 100755 (executable)
@@ -228,7 +228,7 @@ get_image_info() {
         info "Executing: ${cmd}"
         IMAGE="fake_image_info"
         BASE_FILE_NAME="fake-${output_base}"
-        DOWNLOAD_URL="fake_download_url"
+        DOWNLOAD_URL="${image_download_url}"
     else
         debug "Executing: ${cmd}"
         IMAGE_INFO=$( eval ${cmd} )
@@ -251,6 +251,27 @@ get_image_info() {
     debug "Got download URL: '${CYAN}${DOWNLOAD_URL}${NORMAL}'."
 
     info "Got output file: '${GREEN}${OUTPUT_FILE}${NORMAL}'."
+
+    if [[ -z "${BASE_FILE_NAME}" || "${BASE_FILE_NAME}" =~ ^null || -z "${DOWNLOAD_URL}" || "${DOWNLOAD_URL}" =~ ^null ]] ; then
+        error "Error getting image information for RHEL DVD iso image." >&2
+        exit 5
+    fi
+
+}
+
+#------------------------------------------------------------------------------
+download_image() {
+
+    info "Downloading '${GREEN}${OUTPUT_FILE}${NORMAL}' from URL '${GREEN}${DOWNLOAD_URL}${NORMAL}' ..."
+
+    local cmd="curl -o '${OUTPUT_FILE}' '${DOWNLOAD_URL}'"
+
+    if [[ "${SIMULATE}" == "y" ]] ; then
+        info "Executing: ${cmd}"
+    else
+        debug "Executing: ${cmd}"
+        eval ${cmd}
+    fi
 }
 
 #------------------------------------------------------------------------------
@@ -261,6 +282,7 @@ main() {
     set_locale "en_US.utf8"
     get_access_token
     get_image_info
+    download_image
 
 }