-
Notifications
You must be signed in to change notification settings - Fork 0
/
modify_option_group_rds.sh
136 lines (99 loc) · 3.25 KB
/
modify_option_group_rds.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# This is the driver script to Add and Option to an AWS RDS Database Option Group
# Set argument option
ARGC=$#
ARGV=${*:-}
# Load Option parameters from environment file
. ./setEnv.sh
#
# Set AWS Profile
#
AWS_CMD_PROFILE=" --profile ${PROFILENAME}"
#
# AWS RDS add option to option group command line and options
#
CMD="aws $AWS_CMD_PROFILE rds add-option-to-option-group"
if [ $APPLYIMMEDIATELY = "TRUE" ]
then
CMD="$CMD --apply-immediately"
fi
usage () {
echo "Usage: modify_option_group-rds.sh <TDE/SQLNET_ENC/OEM>"
echo
echo "This script, depending upon the Option input parameter supplied above."
echo "will add an option to an AWS database Option Group."
echo
echo "The full AWS command run by the script is:"
echo
echo "${CMD} --option-group-name OPTIONGROUPNAME --options file://./resources/options<optiontemplate>.json "
echo
echo "where OPTIONGROUPNAME as well as Option Group elements are set via variable in setEnv.sh"
echo
echo "options<optiontemplate>.json is a file containing the JSON template for the"
echo "option being added. This JSON file is auto built per Option depending upon the"
echo "Option Group elements chosen:"
echo
echo "TDE --> Oracle TDE - options_tde_template.json"
echo "SQLNET_ENC --> Oracle SQLNET Encryption - options_sqlnet_encr_template.json"
echo "OEM --> Oracle Enterprise Manager control - options_oem_template.json"
echo
echo "Support for other Options including those for mySQL and SQLServer will be"
echo "added in future revisions to this script."
}
# Execute usage block above when user supplies h as script paremeter
while getopts :h option
do
case $option in
"h")
usage
exit ${EXIT_STATUS}
;;
esac
done
# Otherwise record the Option chose from the command-line argument
if [ $ARGC -ne 1 ]
then
usage
exit 2
fi
option=$1
echo "Option Selected is: --->" $option
if [ ${option} = "SQLNET_ENC" ]
then
# Make runtime JSON template from Option template injected with Option environment variables
./bin/makeoption_json_sqlnet_enc
#
# Echo AWS command to be run and then run it
#
CMD="$CMD --option-group-name $OPTIONGROUPNAME --options file://./resources/options${option}.json"
echo "Command to execute:"
echo "-----------------------"
echo $CMD
$CMD
elif [ ${option} = "TDE" ]
then
# Note that TDE has no configurable no options so the base TDE JSON template does
# not have to be injected with any environment variables.
#
# Echo AWS command to be run and then run it
#
CMD="$CMD --option-group-name $OPTIONGROUPNAME --options file://./resources/options${option}.json"
echo "Command to execute:"
echo "-----------------------"
echo $CMD
$CMD
elif [ ${option} = "OEM" ]
then
# Make runtime JSON template from Option template injected with Option environment variables
./bin/makeoption_json_oem
#
# Echo AWS command to be run and then run it
#
CMD="$CMD --option-group-name $OPTIONGROUPNAME --options file://./resources/options${option}.json"
echo "Command to execute:"
echo "-----------------------"
echo $CMD
$CMD
else
echo "No valid option chosen to add to Option Group"
fi