-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
65 lines (47 loc) · 2.02 KB
/
init.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
64
65
#!/bin/bash
###############################################################################
# This script builds auxiliary files that are used by the create-assets.sh
# script and cleans working dir.
###############################################################################
# Sourcing user-provided env properties
source ./config/env.properties
####################################
# Utility function #
####################################
function error_exit {
if [ $? -ne 0 ]; then
echo -e "\033[33m""$1" "\033[0;39m"
if [ $2 ]; then
echo -e "\033[33m"See "$2" file for errors "\033[0;39m"
fi
echo -e "\033[33m"Exiting...
exit 1
fi
}
###################################################
# Creating an asset and mapping service instances #
###################################################
# creating a working dir for JSON files
if [ ! -d "./json_files" ]; then
mkdir ./json_files
elif [ $(ls ./json_files/ | wc -l) -ne 0 ]; then
rm ./json_files/*
fi
# Build the list of API services, service instances, remisions
i=0
for arg; do
export ENVIRONMENT_NAME="$arg"
echo -e "\033[32m""Getting data for the $ENVIRONMENT_NAME environment."
axway central get apisi -s $ENVIRONMENT_NAME -o json >./json_files/api-instances"$i".json
cat ./json_files/api-instances"$i".json | jq -r .[].name >./json_files/apisi"$i".txt
error_exit 'Problem getting Service Instances' "./json_files/apisi$i.txt"
# Also, get all service revisions, as there are several elements that are used during
# Asset creationg
axway central get apisr -s $ENVIRONMENT_NAME -o json >./json_files/api-revisions"$i".json
error_exit 'Problem getting Service Revisions' "./json_files/api-revisions$i.json"
# Also, get all services, as there are several elements that are used during
# Asset creationg
axway central get apis -s $ENVIRONMENT_NAME -o json >./json_files/api-services"$i".json
error_exit 'Problem getting Services' "./json_files/api-services$i.json"
i=$((i + 1))
done