forked from SAP-samples/datahub-integration-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-solution.sh
executable file
·64 lines (51 loc) · 2.17 KB
/
install-solution.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#DI_URL='https://your-data-hub-gateway.tld'
#DI_TEST_TENANT='default'
#DI_TEST_USER='admin'
#DI_TEST_PASSWORD='xxx'
echo "-------------------------"
echo "@@ Installing Solution @@"
echo "-------------------------"
# Prevent bash evaluation of single quoted arguments
# i.e., to prevent evaluation of $ characters in passwords
function CIRUN {
arr=("$@")
#echo "${arr[*]}"
"${arr[@]}"
return $?
}
if [ ! -f "manifest.json" ]; then
echo "Error: Current path seems not to be a vsolution pipeline project (missing 'manifest.json' file)"
exit 1
fi
# Extract solution name from manifest file.
DI_SOLUTION_NAME=$(python -c \
"import json; o = json.load(open(\"manifest.json\")); print(o['name'])") \
|| exit 1
DI_SOLUTION_VERSION=$(python -c \
"import json; o = json.load(open(\"manifest.json\")); print(o['version'])") \
|| exit 1
DI_SOLUTION="$DI_SOLUTION_NAME-$DI_SOLUTION_VERSION"
PACKAGE_NAME="$DI_SOLUTION.zip"
if [ ! -f "$PACKAGE_NAME" ]; then
echo "Error: No solution bundle for solution '$DI_SOLUTION' exists. Please bundle the solution first!"
exit 1
fi
echo "- Sys login..."
CIRUN vctl login $DI_URL $DI_TEST_TENANT $DI_TEST_USER -p $DI_TEST_PASSWORD || exit 1
STRATEGY=$(vctl tenant get-strategy $DI_TEST_TENANT | head -n 1 | xargs)
echo "- Tenant '$DI_TEST_TENANT' is using strategy '$STRATEGY'"
echo "- Stopping pipeline modeler..."
vctl scheduler stop pipeline-modeler
#vctl scheduler stop --all
EXISTING_SOLUTION=$(vctl strategy get $STRATEGY -o json | python -c "import json, sys; o = json.load(sys.stdin); print('\n'.join([s for s in o[u'layers']]))" | grep tsol)
if [ "$EXISTING_SOLUTION" != "" ]; then
echo "- Removing existing solution (maybe old version) '$EXISTING_SOLUTION' from strategy '$STRATEGY'..."
vctl strategy remove $STRATEGY $EXISTING_SOLUTION
fi
echo "- Removing solution '$DI_SOLUTION' from repository (if exists)..."
vctl solution get $DI_SOLUTION_NAME $DI_SOLUTION_VERSION && vctl solution delete $DI_SOLUTION_NAME $DI_SOLUTION_VERSION
echo "- Uploading solution '$DI_SOLUTION' to reposity..."
vctl solution upload $DI_SOLUTION.zip
echo "- Adding solution '$DI_SOLUTION' to strategy '$STRATEGY'..."
vctl strategy add $STRATEGY $DI_SOLUTION