|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2022 Adobe Systems Incorporated |
| 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 | +function usage() { |
| 18 | + echo "Usage: ./update_sdk.sh <SDK path> [dispatcher config directory]" |
| 19 | + echo "Example 1: ./update_sdk.sh /opt/dispatcher-sdks/dispatcher-sdk-2.0.116" |
| 20 | + echo "Example 2: ./update_sdk.sh /opt/dispatcher-sdks/dispatcher-sdk-2.0.116 src" |
| 21 | +} |
| 22 | + |
| 23 | +if [[ -z "$1" ]]; then |
| 24 | + echo "You have to specify a path to an SDK as a parameter!" |
| 25 | + usage |
| 26 | + exit -1 |
| 27 | +fi |
| 28 | + |
| 29 | +sdkPath="$1" |
| 30 | + |
| 31 | +if [[ ! -e "${sdkPath}/bin/docker_run.sh" ]]; then |
| 32 | + echo "Cannot find docker_run.sh file in '${sdkPath}/bin/docker_run.sh'." |
| 33 | + usage |
| 34 | + exit -1 |
| 35 | +fi |
| 36 | + |
| 37 | +sdkVersion=$(cat ${sdkPath}/bin/docker_run.sh | grep version= | cut -f2 -d '=') |
| 38 | + |
| 39 | +if [[ -z "$sdkPath" ]]; then |
| 40 | + echo "Cannot evaluate SDK. Is it a valid path to a dispatcher SDK?" |
| 41 | + usage |
| 42 | + exit -1 |
| 43 | +fi |
| 44 | + |
| 45 | +echo "Attempting to upgrade to dispatcher SDK version $sdkVersion..." |
| 46 | + |
| 47 | +if [[ ! -e "${sdkPath}/bin/update_maven.sh" ]]; then |
| 48 | + echo "The dispatcher SDK version that you have chosen does not yet support updates." |
| 49 | + exit -1 |
| 50 | +fi |
| 51 | + |
| 52 | +if [[ -z "$2" ]]; then |
| 53 | + scriptDir=$(dirname "$0") |
| 54 | + configPath=$scriptDir/src |
| 55 | +else |
| 56 | + configPath="$2" |
| 57 | +fi |
| 58 | + |
| 59 | + |
| 60 | +$sdkPath/bin/update_maven.sh "$configPath" |
0 commit comments