Skip to content

Commit 641a3bc

Browse files
committed
Add an update script that helps to update the dispatcher configuration using a dispatcher SDK
1 parent 42e3870 commit 641a3bc

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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"

src/main/resources/META-INF/archetype-post-generate.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ if ( includeDispatcherConfig == "n"){
9797
def source;
9898
if (aemVersion == 'cloud') {
9999
source = new File(rootDir.getPath(),'dispatcher.cloud')
100+
def updateFile = new File("$source/update_sdk.sh");
101+
updateFile.setExecutable(true, false);
100102
} else {
101103
source = new File(rootDir.getPath(), 'dispatcher.ams')
102104
}

src/main/resources/META-INF/maven/archetype-metadata.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@
272272
<include>**/*.any</include>
273273
<include>**/*.farm</include>
274274
<include>assembly.xml</include>
275+
<include>update_sdk.sh</include>
275276
</includes>
276277
</fileSet>
277278
<fileSet filtered="false" packaged="false" encoding="UTF-8">

0 commit comments

Comments
 (0)