3 # ============LICENSE_START=======================================================
5 # ================================================================================
6 # Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
7 # ================================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 # ============LICENSE_END=========================================================
22 # #################################
24 # #################################
28 echo "Usage: $(basename $0) <application-name> <zipped-application-version> <download-directory>"
29 echo "Example: $(basename $0) controlloop 1.2.0 /opt/policy/config/drools"
33 # #################################
34 # snapshot url computation
35 # #################################
37 function url_snapshot {
38 if [[ $DEBUG == y ]]; then
39 echo "-- ${FUNCNAME[0]} --"
43 APP_URL="${APP_URL}/snapshots/org/onap/policy/drools-applications/${APP_NAME}/packages/apps-${APP_NAME}/${APP_VERSION}"
45 local APP_METADATA_URL="${APP_URL}/maven-metadata.xml"
46 local APP_SNAPSHOT_VERSION=$(curl --silent "${APP_METADATA_URL}" | grep -Po "(?<=<value>).*(?=</value>)" | sort -V | tail -1)
48 if [[ -z ${APP_SNAPSHOT_VERSION} ]]; then
49 echo "ERROR: cannot compute SNAPSHOT version"
54 APP_URL="${APP_URL}/apps-${APP_NAME}-${APP_SNAPSHOT_VERSION}.zip"
57 # #################################
58 # release url computation
59 # #################################
61 function url_release {
62 if [[ $DEBUG == y ]]; then
63 echo "-- ${FUNCNAME[0]} --"
67 APP_URL="${APP_URL}/releases/org/onap/policy/drools-applications/${APP_NAME}/packages/apps-${APP_NAME}/${APP_VERSION}/apps-${APP_NAME}-${APP_VERSION}.zip"
70 # #################################
72 # #################################
74 if [[ $DEBUG == y ]]; then
79 if [[ -z ${APP_NAME} ]]; then
80 echo "ERROR: no APPLICATION NAME provided (ie. controlloop)"
86 if [[ -z ${APP_VERSION} ]]; then
87 echo "ERROR: no APPLICATION VERSION provided"
93 if [[ -z ${DOWNLOAD_DIR} ]]; then
94 echo "ERROR: no DOWNLOAD DIRECTORY provided"
99 if [[ ! -d ${DOWNLOAD_DIR} ]]; then
100 echo "ERROR: ${DOWNLOAD_DIR} is not a directory"
105 APP_GROUP_ID="org.onap.policy.drools-applications.${APP_NAME}.packages"
106 APP_ARTIFACT_ID="apps-${APP_NAME}"
107 APP_BASE_URL="https://nexus.onap.org/content/repositories"
109 APP_URL="${APP_BASE_URL}"
111 if [[ ${APP_VERSION} =~ \-SNAPSHOT$ ]]; then
117 wget "${APP_URL}" -O "${DOWNLOAD_DIR}"/apps-"${APP_NAME}".zip
118 if [[ $? != 0 ]]; then
119 echo "ERROR: cannot download ${DOWNLOAD_DIR}/apps-${APP_NAME}.zip"
123 echo "APP ${APP_NAME} stored at ${DOWNLOAD_DIR}/apps-${APP_NAME}.zip"
124 ls -l "${DOWNLOAD_DIR}"/apps-"${APP_NAME}".zip