From 1ca48387a2630d696d11bd6e2d6180be7aa23f27 Mon Sep 17 00:00:00 2001 From: Devipriya Selvarajan Date: Wed, 16 Oct 2024 18:16:46 +0530 Subject: [PATCH] Add base mq download script --- Makefile | 4 ++-- download-basemq.sh | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100755 download-basemq.sh diff --git a/Makefile b/Makefile index 4f983a17..63e4fa9d 100644 --- a/Makefile +++ b/Makefile @@ -251,7 +251,7 @@ else ifneq "$(MQ_ARCHIVE_REPOSITORY_DEV)" "$(EMPTY)" curl --fail --user $(MQ_ARCHIVE_REPOSITORY_USER):$(MQ_ARCHIVE_REPOSITORY_CREDENTIAL) --request GET "$(MQ_ARCHIVE_REPOSITORY_DEV)" --output downloads/$(MQ_ARCHIVE_DEV) else - curl --fail --location https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/$(MQ_ARCHIVE_DEV) --output downloads/$(MQ_ARCHIVE_DEV) + ./download-basemq.sh -r $(MQ_ARCHIVE_DEV) -v $(MQ_VERSION_VRM) endif endif @@ -576,4 +576,4 @@ ifneq (,$(findstring docker,$(COMMAND))) endif ifneq (,$(findstring podman,$(COMMAND))) @test "$(word 1,$(subst ., ,$(PODMAN_VERSION)))" -ge "1" || (echo "Error: Podman version 1.0 or greater is required" && exit 1) -endif \ No newline at end of file +endif diff --git a/download-basemq.sh b/download-basemq.sh new file mode 100755 index 00000000..d0c08015 --- /dev/null +++ b/download-basemq.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# © Copyright IBM Corporation 2024 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +while getopts r:v: flag +do + case "${flag}" in + r) MQ_ARCHIVE_DEV=${OPTARG};; + v) MQ_VERSION_VRM=${OPTARG};; + esac +done + +if [[ -z $MQ_ARCHIVE_DEV || -z $MQ_VERSION_VRM ]] ; then + printf "${ERROR}MQ driver download script parameters missing!${END}\n" + exit 1 +fi + +BASE_MQ_LOCATION="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv" + +FILE_FOUND=$(curl -I $BASE_MQ_LOCATION/$MQ_ARCHIVE_DEV -w "%{http_code}" -s -o /dev/null) + +if [ "$FILE_FOUND" -eq 200 ]; then + curl --fail --location $BASE_MQ_LOCATION/$MQ_ARCHIVE_DEV --output downloads/"$MQ_ARCHIVE_DEV" + +elif [ "$FILE_FOUND" -eq 404 ]; then + curl -s --list-only --location $BASE_MQ_LOCATION | sed 's/href=/\nhref=/g' |grep href=\" |sed 's/.*href="//g;s/".*//g' > downloads/base-mq-file-list.txt + echo "$MQ_ARCHIVE_DEV is not available at $BASE_MQ_LOCATION" && echo "=================================================" + grep "$MQ_VERSION_VRM" downloads/base-mq-file-list.txt| grep "IBM-MQ-" && echo "=================================================" && echo "$MQ_VERSION_VRM images available in the download site are listed above" + echo "Choose any of the available version and run build command for example,'MQ_VERSION=9.4.0.0 make build-devserver'" + rm -f downloads/base-mq-file-list.txt + exit 1 +else + echo "Unexpected error when downloading MQ driver from $BASE_MQ_LOCATION" + exit 1 +fi