forked from OraOpenSource/OXAR
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·234 lines (193 loc) · 6.31 KB
/
build.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
#!/bin/bash
#build.sh
#Notes
#
#Some input is required before running
#Search for CHANGEME and modify before running
#
#
#- Passwords
#All passwords (expect for APEX Admin) are set to "oracle" by default. You can change accordingly
#
#
#- ratom
#This tool allows you to edit files in atom on your desktop rather than vi on server
#You must install the Atom editor: https://atom.io/ along with the Remote Atom plugin: https://github.com/randy3k/remote-atom
#When connecting to server use:
#ssh -R 52698:localhost:52698 root@<server_name/ip>
#
#To edit a file on the server, simply type:
#ratom <my_file> and then look in your Atom editor to modify
#*** LINUX ***
OOS_SOURCE="${BASH_SOURCE[0]}"
while [ -h "$OOS_SOURCE" ]; do # resolve $OOS_SOURCE until the file is no longer a symlink
OOS_SOURCE_DIR="$( cd -P "$( dirname "$OOS_SOURCE" )" && pwd )"
OOS_SOURCE="$(readlink "$OOS_SOURCE")"
[[ $OOS_SOURCE != /* ]] && OOS_SOURCE="$OOS_SOURCE_DIR/$OOS_SOURCE" # if $OOS_SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
OOS_SOURCE_DIR="$( cd -P "$( dirname "$OOS_SOURCE" )" && pwd )"
if [[ $(whoami) != "root" ]]; then
echo "This program must be run as root." >&2
echo "Try: sudo ${OOS_SOURCE_DIR}/${OOS_SOURCE}" >&2
exit 1
fi
# Get the exit status in sourced scripts to follow the called script instead of tee
# See: http://stackoverflow.com/a/6872163/3476713
set -o pipefail
#Parsing arguments adapted from: http://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
OOS_VERBOSE_OUT=false
# #166 Debug mode
OOS_DEBUG=false
while [[ $# > 0 ]]; do
key="$1"
case $key in
-v|--verbose)
OOS_VERBOSE_OUT=true
;;
-d|--debug)
OOS_DEBUG=true
;;
*)
echo "Unsupported flag: $key"
exit 1;
esac
shift
done
OOS_UTILS_DIR=${OOS_SOURCE_DIR}/utils
OOS_LOG_DIR=${OOS_SOURCE_DIR}/logs
OOS_INSTALL_LOG=${OOS_LOG_DIR}/install.log
OOS_ERROR_LOG=${OOS_LOG_DIR}/error.log
if [ "$OOS_VERBOSE_OUT" = true ]; then
OOS_LOG_OPTIONS=" > >(tee ${OOS_INSTALL_LOG} --append) 2> >(tee ${OOS_ERROR_LOG} --append >&2)"
else
OOS_LOG_OPTIONS=" >> ${OOS_INSTALL_LOG} 2> >(tee ${OOS_ERROR_LOG} --append >&2)"
fi
mkdir -p ${OOS_LOG_DIR}
# Create empty log files
> ${OOS_INSTALL_LOG}
> ${OOS_ERROR_LOG}
mkdir -p $OOS_SOURCE_DIR/tmp
cd $OOS_SOURCE_DIR
# #149 Unzip and Java are pre-requisites for configuration validations
if [ -n "$(command -v yum)" ]; then
echo; echo \* Installing packages with yum \*
yum update -y
yum install \
unzip \
java \
-y
elif [ -n "$(command -v apt-get)" ]; then
echo; echo \* Installing packages with apt-get \*
apt-get update -y
apt-get install \
unzip \
openjdk-8-jdk \
-y
else
echo; echo \* No known package manager found \*
fi
#See http://stackoverflow.com/questions/692000/how-do-i-write-stderr-to-a-file-while-using-tee-with-a-pipe
#and http://stackoverflow.com/questions/21465297/tee-stdout-and-stderr-to-separate-files-while-retaining-them-on-their-respective
#Load configurations
. ${OOS_UTILS_DIR}/echo_title.sh "Loading configurations"
eval "source ./config.sh $OOS_LOG_OPTIONS"
# Dependencies
. ${OOS_UTILS_DIR}/echo_title.sh "Running updates"
cd $OOS_SOURCE_DIR
eval "source ./scripts/packages.sh $OOS_LOG_OPTIONS"
if [ "$OOS_DEBUG" = true ]; then
read -rsp $'Packages installed. Press enter to continue...\n'
fi
#Install ratom
. ${OOS_UTILS_DIR}/echo_title.sh "Installing ratom"
if [ "$(which ratom)" == "" ]; then
cd $OOS_SOURCE_DIR
eval "source ./scripts/ratom.sh $OOS_LOG_OPTIONS"
else
echo ratom already installed
fi
#Oracle install
if [ "$OOS_MODULE_ORACLE" = "Y" ]; then
#Expand swap
. ${OOS_UTILS_DIR}/echo_title.sh "Expanding Swap Space"
cd $OOS_SOURCE_DIR
eval "source ./scripts/swap_space.sh $OOS_LOG_OPTIONS"
. ${OOS_UTILS_DIR}/echo_title.sh "Installing Oracle XE"
cd $OOS_SOURCE_DIR
eval "source ./scripts/oraclexe.sh $OOS_LOG_OPTIONS"
#Oracle config
. ${OOS_UTILS_DIR}/echo_title.sh "Oracle Config"
cd $OOS_SOURCE_DIR
eval "source ./scripts/oracle_config.sh $OOS_LOG_OPTIONS"
fi
if [ "$OOS_DEBUG" = true ]; then
read -rsp $'Oracle installed. Press enter to continue...\n'
fi
#APEX install
if [ "$OOS_MODULE_APEX" = "Y" ]; then
. ${OOS_UTILS_DIR}/echo_title.sh "Installing APEX"
cd $OOS_SOURCE_DIR
eval "source ./scripts/apex.sh $OOS_LOG_OPTIONS"
. ${OOS_UTILS_DIR}/echo_title.sh "Configuring APEX"
cd $OOS_SOURCE_DIR
eval "source ./scripts/apex_config.sh $OOS_LOG_OPTIONS"
fi
if [ "$OOS_DEBUG" = true ]; then
read -rsp $'APEX installed. Press enter to continue...\n'
fi
#12: Install Oracle Node driver
if [ "$OOS_MODULE_NODE_ORACLEDB" = "Y" ]; then
. ${OOS_UTILS_DIR}/echo_title.sh "Installing node-oracledb"
cd $OOS_SOURCE_DIR
eval "source ./scripts/node-oracledb.sh $OOS_LOG_OPTIONS"
fi
#Node4ORDS
if [ "$OOS_MODULE_NODE4ORDS" = "Y" ]; then
. ${OOS_UTILS_DIR}/echo_title.sh "Installing Node4ORDS"
cd $OOS_SOURCE_DIR
eval "source ./scripts/node4ords.sh $OOS_LOG_OPTIONS"
fi
#Tomcat
if [ "$OOS_MODULE_TOMCAT" = "Y" ]; then
. ${OOS_UTILS_DIR}/echo_title.sh "Installing Tomcat"
cd $OOS_SOURCE_DIR
eval "source ./scripts/tomcat.sh $OOS_LOG_OPTIONS"
fi
#Firewalld
. ${OOS_UTILS_DIR}/echo_title.sh "Configuring firewalld"
cd $OOS_SOURCE_DIR
eval "source ./scripts/firewalld.sh $OOS_LOG_OPTIONS"
#ORDS
#This includes some manual intervention now
if [ "$OOS_MODULE_ORDS" = "Y" ]; then
. ${OOS_UTILS_DIR}/echo_title.sh "Installing ORDS"
cd $OOS_SOURCE_DIR
eval "source ./scripts/ords.sh $OOS_LOG_OPTIONS"
fi
if [ "$OOS_DEBUG" = true ]; then
read -rsp $'ORDS installed. Press enter to continue...\n'
fi
#SQLcl
if [ "$OOS_MODULE_SQLCL" = "Y" ]; then
. ${OOS_UTILS_DIR}/echo_title.sh "Installing SQLcl"
cd $OOS_SOURCE_DIR
eval "source ./scripts/sqlcl.sh $OOS_LOG_OPTIONS"
fi
# Add Ons
if [ "$OOS_MODULE_APEX" ] && [ "$OOS_AOP_YN" = "Y" ]; then
. ${OOS_UTILS_DIR}/echo_title.sh "Installing AOP"
cd $OOS_SOURCE_DIR
eval "source ./addons/aop/aop.sh $OOS_LOG_OPTIONS"
if [ "$OOS_DEBUG" = true ]; then
read -rsp $'AOP installed. Press enter to continue...\n'
fi
fi
#*** CLEANUP ***
# Leave files for now
# echo; echo \* Cleanup \*; echo
# cd $OOS_SOURCE_DIR
# rm -rf tmp
#Reboot
echo "Installation complete. You can review logs at ${OOS_LOG_DIR}"
echo Rebooting in: ; for i in {15..1..1};do echo -n "$i." && sleep 1; done
shutdown -r now