-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathconfig.sh
More file actions
executable file
·71 lines (61 loc) · 1.63 KB
/
config.sh
File metadata and controls
executable file
·71 lines (61 loc) · 1.63 KB
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
#!/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 -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" == "-i" ]; then
./config.sh TO
./config.sh BASE_IMAGE_PATH
./config.sh REGISTRY
./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
CMD="cp -f ./.env ./.env.bak; cat ./.env | sed \"s#^export $1=.*#export $1=${NEW_VALUE}#\" | tee ./.env > /dev/null; echo ''; echo New value:; cat ./.env | grep \"^export $1=\""
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