-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfig.sh
executable file
·118 lines (108 loc) · 3.11 KB
/
config.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
######################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
# SPDX-License-Identifier: MIT-0 #
######################################################################
. ./.env
if [ "${DEBUG}" == "true" ]; then
set -x
fi
function usage
{
echo ""
echo "Usage: $0 [setting] [value]"
echo ""
echo " $0 --help - display usage information"
echo " $0 --show - show the values of all settings"
echo " $0 --show [setting] - show the value of the specified setting"
echo " $0 -i - edit selected settings interactively"
echo " $0 - edit configuration file"
echo " $0 setting - edit specified setting interactively"
echo " $0 setting value - set the specified setting to the provided value"
echo ""
}
if [ "$1" == "--help" ]; then
usage
CMD=""
elif [ "$1" == "--show" ]; then
if [ "$2" == "" ]; then
env
else
eval echo \$$2
fi
elif [ "$1" == "-i" ]; then
./config.sh TO
./config.sh BASE_IMAGE_PATH
./config.sh IMAGE_NAME
./config.sh VERSION
elif [ "$1" == "" ]; then
CMD="${CMD_EDIT} .env"
else
if [ "$2" == "" ]; then
# Interactive
echo ""
cat ./.env | grep "^export $1=" -B 10
echo ""
CURRENT_VALUE=$(printenv $1)
echo "Set $1 [ ${CURRENT_VALUE} ] to: "
read NEW_VALUE
if [ "${NEW_VALUE}" == "" ]; then
NEW_VALUE="${CURRENT_VALUE}"
fi
else
# Set value to $2
NEW_VALUE="$2"
fi
if [ "$1" == "REGISTRY" ]; then
CMD=""
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.registry
elif [ "$1" == "AWS_ACCESS_KEY_ID" ]; then
CMD=""
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.aws_id
elif [ "$1" == "AWS_SECRET_ACCESS_KEY" ]; then
CMD=""
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.aws_cr
elif [ "$1" == "PM_GRAPHDB_SYSTEM_CR" ]; then
CMD=""
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.graphdb_system_cr
elif [ "$1" == "PM_GRAPHDB_ID" ]; then
CMD=""
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.graphdb_id
elif [ "$1" == "PM_GRAPHDB_CR" ]; then
CMD=""
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.graphdb_cr
elif [ "$1" == "PM_S3_BUCKET" ]; then
CMD=""
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.s3b
elif [ "$1" == "PV_TYPE" ]; then
CMD=""
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.pv_type
elif [ "$1" == "EFS_VOLUME_ID" ]; then
CMD=""
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.efs
elif [ "$1" == "ALB_ALLOW_CIDRS" ]; then
CMD=""
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.allow
elif [ "$1" == "PM_PLATFORM_SCALE" ]; then
CMD=""
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.platform
elif [ "$1" == "KCFG_ENC" ]; then
CMD=""
echo "NEW_VALUE is:"
echo "${NEW_VALUE}"
echo "${NEW_VALUE}" > ${PM_ROOT_PATH}/.kcfg
else
CMD="cp -f ./.env ./.env.bak; cat ./.env | sed \"s#^export $1=.*#export $1=${NEW_VALUE}#\" | tee ./.env > /dev/null; echo ''; if [ "$VERBOSE" == "true" ]; then echo New value:; cat ./.env | grep \"^export $1=\"; fi"
fi
fi
if [ "${VERBOSE}" == "true" ]; then
echo ""
echo "${CMD}"
fi
if [ "${DRY_RUN}" == "false" ]; then
eval "${CMD}"
echo ""
fi
if [ "${DEBUG}" == "true" ]; then
set +x
fi