-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·255 lines (196 loc) · 6.63 KB
/
install.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/bin/bash
##############################################################################################################
quick_install=${1:-"N"}
docker_network=${2:-'oracle_network'}
db_file_name=${3:-'oracle-database-xe-18c-1.0-1.x86_64.rpm'}
db_version=${4:-'18c'}
db_sys_pwd=${5:-'oracle'}
db_port=${6:-31521}
em_port=${7:-35500}
apex_file_name=${8:-'apex_19.1.zip'}
apex_version=${9:-'19.1'}
apex_admin_username=${10:-'ADMIN'}
apex_admin_pwd=${11:-'Welc0me@1'}
apex_admin_email=${12:-'wfgdlut@gmail.com'}
ords_file_name=${13:-'ords-19.2.0.199.1647.zip'}
ords_version=${14:-'19.2.0'}
ords_port=${15:-32513}
ip_address=${16:-'localhost'}
url_check=""
fileName=""
docker_prefix='rapid-apex'
oss_url='https://oracle-apex-bucket.s3.ap-northeast-1.amazonaws.com/'
echo ">>> print all of input parameters..."
echo $*
echo ">>> end of print all of input parameters..."
##############################################################################################################
echo ""
echo "--------- Step 1: Download installation media ---------"
echo ""
work_path=`pwd`
echo ">>> current work path is $work_path"
# check if url is valid
function httpRequest()
{
unset url_check
#curl request
info=`curl -s -m 10 --connect-timeout 10 -I $1`
#get return code
code=`echo $info|grep "HTTP"|awk '{print $2}'`
#check return code
if [ "$code" != "200" ];then
echo ">>> $1 cannot be touched..."
url_check="N"
fi
}
# download installation file
function download()
{
fileUrl=$1
fileName=""
echo "fileUrl=$fileUrl"
if [[ $1 =~ "/" ]]; then
# user has downloaded the file, just copy it
if [[ ${fileUrl:0:1} == "/" ]]; then
echo ">>> copy installation file to files folder"
fileName=${fileUrl##*"/"}
cp $fileUrl .
else
# download from url user provided
echo ">>> download installation file from the url user provided"
httpRequest "$fileUrl"
if [ "$url_check" = "N" ]; then
fileName=""
exit;
else
fileName=${fileUrl##*"/"}
curl -o $fileName $fileUrl
fi
fi;
else
# try to download installation file from default repository
fileName=$fileUrl
echo ">>> download $fileName from $oss_url"
if [ ! -f $fileName ]; then
httpRequest "$oss_url$fileName"
if [ "$url_check" = "N" ]; then
exit;
else
curl -o $fileName $oss_url$fileName
fi
fi
fi;
}
# download apex installation file
cd $work_path/docker-xe/files
download $apex_file_name
apex_file_name=$fileName
echo ">>> apex_file_name="$apex_file_name
echo ""
# download ords installation file
cd $work_path/docker-ords/files
download $ords_file_name
ords_file_name=$fileName
echo ">>> ords_file_name="$ords_file_name
echo ""
# download oracle db installation file
cd $work_path/docker-xe/files
download $db_file_name
db_file_name=$fileName
echo ">>> db_file_name="$db_file_name
echo ""
cd $work_path/docker-xe
if [ ! -d ../apex ]; then
echo ">>> unzip apex installation media ..."
mkdir ../apex
cp scripts/apex-install* ../apex/
unzip -oq files/$apex_file_name -d ../ &
fi;
echo ""
echo "--------- Step 2: compile oracle xe docker image ---------"
echo ""
echo ">>> docker image $docker_prefix/oracle-xe:$db_version does not exist, begin to build docker image..."
docker build -t $docker_prefix/oracle-xe:$db_version --build-arg DB_SYS_PWD=$db_sys_pwd .
echo ""
echo "--------- Step 3: startup oracle xe docker image ---------"
echo ""
docker run -d \
-p $db_port:1521 \
-p $em_port:5500 \
--name=oracle-xe \
--volume $work_path/oradata:/opt/oracle/oradata \
--volume $work_path/apex:/tmp/apex \
--network=$docker_network \
$docker_prefix/oracle-xe:$db_version
# wait until database configuration is done
rm -f xe_installation.log
docker logs oracle-xe >& xe_installation.log
while : ; do
[[ `grep "Completed: ALTER PLUGGABLE DATABASE" xe_installation.log` ]] && break
docker logs oracle-xe >& xe_installation.log
echo "wait until oracle-xe configuration is done..."
sleep 10
done
##############################################################################################################
echo ""
echo "--------- Step 4: install apex on xe docker image ---------"
echo ""
docker exec -it oracle-xe bash -c "source /home/oracle/.bashrc && cd /tmp/apex && chmod +x apex-install.sh && . apex-install.sh XEPDB1 $db_sys_pwd $apex_admin_username $apex_admin_pwd $apex_admin_email"
##############################################################################################################
echo ""
echo "--------- Step 5: compile oracle ords docker image ---------"
echo ""
cd $work_path/docker-ords/
if [[ "$(docker images -q $docker_prefix/oracle-ords:$ords_version 2> /dev/null)" == "" ]]; then
echo ">>> docker image $docker_prefix/oracle-ords:$ords_version does not exist, begin to build docker image..."
docker build -t $docker_prefix/oracle-ords:$ords_version .
else
echo ">>> docker image $docker_prefix/oracle-ords:$ords_version is found, skip compile step and go on..."
fi;
##############################################################################################################
echo ""
echo "--------- Step 6: startup oracle ords docker image ---------"
echo ""
docker run -d -it --network=$docker_network \
-e TZ=Asia/Shanghai \
-e DB_HOSTNAME=oracle-xe \
-e DB_PORT=1521 \
-e DB_SERVICENAME=XEPDB1 \
-e APEX_PUBLIC_USER_PASS=oracle \
-e APEX_LISTENER_PASS=oracle \
-e APEX_REST_PASS=oracle \
-e ORDS_PASS=oracle \
-e SYS_PASS=$db_sys_pwd \
-e TOMCAT_FILE_NAME=$tomcat_file_name \
--volume $work_path/oracle-ords/$ords_version/config:/opt/ords \
--volume $work_path/apex/images:/ords/apex-images \
-p $ords_port:8080 \
$docker_prefix/oracle-ords:$ords_version
cd $work_path
echo ""
echo "----------------------- APEX Info -----------------------"
echo ""
echo "Admin URL: http://$ip_address:$ords_port/ords"
echo "Workspace: INTERNAL"
echo "User Name: $apex_admin_username"
echo "Password: $apex_admin_pwd"
echo ""
echo "------------------------ DB Info ------------------------"
echo ""
echo "CDB: sqlplus sys/$db_sys_pwd@$ip_address:$db_port/XE as sysdba"
echo "PDB: sqlplus sys/$db_sys_pwd@$ip_address:$db_port/XEPDB1 as sysdba"
echo ""
echo "---------------------- Config Info ----------------------"
echo ""
echo "Database Data File: $work_path/oradata/"
echo "ORDS Config File: $work_path/oracle-ords/"
echo ""
echo "---------------------- Docker Info ----------------------"
echo ""
echo "docker images"
echo "docker ps -a"
echo ""
echo "--------- All installations are done, enjoy it! ---------"
echo ""
echo "star me if you like it: https://github.com/wfg2513148/rapid-apex"
echo ""