|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# © Copyright IBM Corporation 2024 |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +while getopts r:v: flag |
| 18 | +do |
| 19 | + case "${flag}" in |
| 20 | + r) MQ_ARCHIVE_DEV=${OPTARG};; |
| 21 | + v) MQ_VERSION_VRM=${OPTARG};; |
| 22 | + esac |
| 23 | +done |
| 24 | + |
| 25 | +if [[ -z $MQ_ARCHIVE_DEV || -z $MQ_VERSION_VRM ]] ; then |
| 26 | + printf "${ERROR}MQ driver download script parameters missing!${END}\n" |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | + |
| 30 | +BASE_MQ_LOCATION="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv" |
| 31 | + |
| 32 | +FILE_FOUND=$(curl -I $BASE_MQ_LOCATION/$MQ_ARCHIVE_DEV -w "%{http_code}" -s -o /dev/null) |
| 33 | + |
| 34 | +if [ "$FILE_FOUND" -eq 200 ]; then |
| 35 | + curl --fail --location $BASE_MQ_LOCATION/$MQ_ARCHIVE_DEV --output downloads/"$MQ_ARCHIVE_DEV" |
| 36 | + |
| 37 | +elif [ "$FILE_FOUND" -eq 404 ]; then |
| 38 | + 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 |
| 39 | + echo "$MQ_ARCHIVE_DEV is not available at $BASE_MQ_LOCATION" && echo "=================================================" |
| 40 | + 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" |
| 41 | + echo "Choose any of the available version and run build command for example,'MQ_VERSION=9.4.0.0 make build-devserver'" |
| 42 | + rm -f downloads/base-mq-file-list.txt |
| 43 | + exit 1 |
| 44 | +else |
| 45 | + echo "Unexpected error when downloading MQ driver from $BASE_MQ_LOCATION" |
| 46 | + exit 1 |
| 47 | +fi |
0 commit comments