3 # ============LICENSE_START=======================================================
5 # ================================================================================
6 # Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
7 # Modifications Copyright © 2018 Amdocs, Bell Canada
8 # ================================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END=========================================================
23 # #################################
25 # #################################
29 echo "Usage: $(basename $0) <application-name> <zipped-application-version> <download-directory>"
30 echo "Example: $(basename $0) controlloop 1.2.0 /opt/policy/config/drools"
34 # #################################
35 # snapshot url computation
36 # #################################
38 function url_snapshot {
39 if [[ $DEBUG == y ]]; then
40 echo "-- ${FUNCNAME[0]} --"
44 APP_URL="${APP_URL}/snapshots/org/onap/policy/drools-applications/${APP_NAME}/packages/apps-${APP_NAME}/${APP_VERSION}"
46 local APP_METADATA_URL="${APP_URL}/maven-metadata.xml"
47 local APP_SNAPSHOT_VERSION=$(curl --silent "${APP_METADATA_URL}" | grep -Po "(?<=<value>).*(?=</value>)" | sort -V | tail -1)
49 if [[ -z ${APP_SNAPSHOT_VERSION} ]]; then
50 echo "ERROR: cannot compute SNAPSHOT version"
55 APP_URL="${APP_URL}/apps-${APP_NAME}-${APP_SNAPSHOT_VERSION}.zip"
58 # #################################
59 # release url computation
60 # #################################
62 function url_release {
63 if [[ $DEBUG == y ]]; then
64 echo "-- ${FUNCNAME[0]} --"
68 APP_URL="${APP_URL}/releases/org/onap/policy/drools-applications/${APP_NAME}/packages/apps-${APP_NAME}/${APP_VERSION}/apps-${APP_NAME}-${APP_VERSION}.zip"
71 # #################################
73 # #################################
75 if [[ $DEBUG == y ]]; then
80 if [[ -z ${APP_NAME} ]]; then
81 echo "ERROR: no APPLICATION NAME provided (ie. controlloop)"
87 if [[ -z ${APP_VERSION} ]]; then
88 echo "ERROR: no APPLICATION VERSION provided"
94 if [[ -z ${DOWNLOAD_DIR} ]]; then
95 echo "ERROR: no DOWNLOAD DIRECTORY provided"
100 if [[ ! -d ${DOWNLOAD_DIR} ]]; then
101 echo "ERROR: ${DOWNLOAD_DIR} is not a directory"
106 APP_GROUP_ID="org.onap.policy.drools-applications.${APP_NAME}.packages"
107 APP_ARTIFACT_ID="apps-${APP_NAME}"
108 APP_BASE_URL="https://nexus.onap.org/content/repositories"
110 APP_URL="${APP_BASE_URL}"
112 if [[ ${APP_VERSION} =~ \-SNAPSHOT$ ]]; then
118 wget "${APP_URL}" -O "${DOWNLOAD_DIR}"/apps-"${APP_NAME}".zip
119 if [[ $? != 0 ]]; then
120 echo "ERROR: cannot download ${DOWNLOAD_DIR}/apps-${APP_NAME}.zip"
124 echo "APP ${APP_NAME} stored at ${DOWNLOAD_DIR}/apps-${APP_NAME}.zip"
125 ls -l "${DOWNLOAD_DIR}"/apps-"${APP_NAME}".zip