1
1
#! /bin/bash
2
2
#
3
3
#
4
- # Copyright (c) 2014- 2019 Oracle and/or its affiliates. All rights reserved.
4
+ # Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved.
5
5
#
6
6
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
7
7
#
8
- # If AdminServer.log does not exists, container is starting for 1st time
9
- # So it should start NM and also associate with AdminServer
10
- # Otherwise, only start NM (container restarted)
8
+ # Define DOMAIN_HOME
9
+
10
+ # get domain properties from domain.properties file
11
+ DOMAIN_PROPERTIES_FILE=/u01/weblogic/domain.properties
12
+ if [ -e " ${DOMAIN_PROPERTIES_FILE} " ]; then
13
+ DOMAIN_NAME=` awk ' {print $1}' $DOMAIN_PROPERTIES_FILE | grep DOMAIN_NAME | cut -d " =" -f2`
14
+ CONNECTION_STRING=` awk ' {print $1}' $DOMAIN_PROPERTIES_FILE | grep CONNECTION_STRING | cut -d " =" -f2`
15
+ RCUPREFIX=` awk ' {print $1}' $DOMAIN_PROPERTIES_FILE | grep RCUPREFIX | cut -d " =" -f2`
16
+ ADMIN_LISTEN_PORT=` awk ' {print $1}' $DOMAIN_PROPERTIES_FILE | grep ADMIN_LISTEN_PORT | cut -d " =" -f2`
17
+ ADMIN_NAME=` awk ' {print $1}' $DOMAIN_PROPERTIES_FILE | grep ADMIN_NAME | cut -d " =" -f2`
18
+ ADMINISTRATION_PORT_ENABLED=` awk ' {print $1}' $DOMAIN_PROPERTIES_FILE | grep ADMINISTRATION_PORT_ENABLED | cut -d " =" -f2`
19
+ ADMINISTRATION_PORT=` awk ' {print $1}' $DOMAIN_PROPERTIES_FILE | grep ADMINISTRATION_PORT= | cut -d " =" -f2`
20
+ MANAGED_NAME=` awk ' {print $1}' $DOMAIN_PROPERTIES_FILE | grep MANAGED_NAME | cut -d " =" -f2`
21
+ MANAGEDSERVER_PORT=` awk ' {print $1}' $DOMAIN_PROPERTIES_FILE | grep MANAGEDSERVER_PORT | cut -d " =" -f2`
22
+ PRODUCTION_MODE=` awk ' {print $1}' $DOMAIN_PROPERTIES_FILE | grep PRODUCTION_MODE | cut -d " =" -f2`
23
+ fi
24
+ export DOMAIN_ROOT=" /shared/domains"
25
+ export DOMAIN_HOME=${DOMAIN_ROOT} /${DOMAIN_NAME}
26
+ echo " Domain Home is: " $DOMAIN_HOME
27
+
11
28
# ########## SIGTERM handler ############
12
29
function _term() {
13
30
echo " Stopping container."
@@ -20,19 +37,6 @@ function _kill() {
20
37
echo " SIGKILL received, shutting down the server!"
21
38
kill -9 $childPID
22
39
}
23
- # ####Random Password Generation########
24
- function rand_pwd(){
25
- while true ; do
26
- s=$( cat /dev/urandom | tr -dc " A-Za-z0-9" | fold -w 8 | head -n 1)
27
- if [[ ${# s} -ge 8 && " $s " == * [A-Z]* && " $s " == * [a-z]* && " $s " == * [0-9]* ]]
28
- then
29
- break
30
- else
31
- echo " Password does not Match the criteria, re-generating..." >&2
32
- fi
33
- done
34
- echo " ${s} "
35
- }
36
40
37
41
# Set SIGTERM handler
38
42
trap _term SIGTERM
@@ -41,160 +45,170 @@ trap _term SIGTERM
41
45
trap _kill SIGKILL
42
46
43
47
echo " Configuring Domain for first time "
44
- echo " If Domain has already been Configured"
45
48
echo " Start the Admin and Managed Servers "
46
49
echo " ====================================="
47
50
48
- export CONNECTION_STRING=%CONNECTION_STRING%
49
- export RCUPREFIX=%RCUPREFIX%
50
- export DB_PASSWORD=Oradoc_db1
51
- export DB_USERNAME=sys
52
- export ADMIN_PASSWORD=welcome1
53
- export DB_SCHEMA_PASSWORD=Welcome1
54
- export DOMAIN_NAME=%DOMAIN_NAME%
55
-
56
51
# Check that the User has passed on all the details needed to configure this image
57
52
# Settings to call RCU....
58
53
echo " CONNECTION_STRING=${CONNECTION_STRING:? " Please set CONNECTION_STRING for connecting to the Database" } "
59
54
echo " RCUPREFIX=${RCUPREFIX:? " Please set RCUPREFIX for the database schemas" } "
60
55
echo " DOMAIN_NAME=${DOMAIN_NAME:? " Please set DOMAIN_NAME for creating the new Domain" } "
56
+ echo " DOMAIN_HOME=$DOMAIN_HOME "
57
+
58
+ # Settings to call domain creation ...
59
+ echo " ADMIN_LISTEN_PORT=${ADMIN_LISTEN_PORT:- 7001} "
60
+ echo " ADMIN_NAME=${ADMIN_NAME:- AdminServer} "
61
+ echo " ADMINISTRATION_PORT_ENABLED=${ADMINISTRATION_PORT_ENABLED:- true} "
62
+ echo " ADMINISTRATION_PORT=${ADMINISTRATION_PORT:- 9002} "
63
+ echo " MANAGED_NAME=${MANAGED_NAME:- infraServer1} "
64
+ echo " MANAGEDSERVER_PORT=${MANAGEDSERVER_PORT:- 8001} "
65
+ echo " PRODUCTION_MODE=${PRODUCTION_MODE:- prod} "
61
66
62
67
RUN_RCU=" true"
63
68
CONTAINERCONFIG_DIR=/u01/oracle/ContainerData
64
69
export CONNECTION_STRING=$CONNECTION_STRING
65
70
export RCUPREFIX=$RCUPREFIX
66
71
67
- export DB_USERNAME=$DB_USERNAME
68
- export DB_PASSWORD=$DB_PASSWORD
69
-
70
72
export jdbc_url=" jdbc:oracle:thin:@" $CONNECTION_STRING
71
73
72
- # Set the password for RCU
73
- echo -e $DB_PASSWORD " \n" $DB_SCHEMA_PASSWORD > /u01/oracle/pwd.txt
74
74
75
75
echo " Loading RCU Phase"
76
76
echo " ================="
77
77
78
78
echo " CONNECTION_STRING=$CONNECTION_STRING "
79
79
echo " RCUPREFIX=$RCUPREFIX "
80
- echo " DB_PASSWORD=$DB_PASSWORD "
81
80
echo " jdbc_url=$jdbc_url "
82
- echo " ADMIN_PASSWORD=$ADMIN_PASSWORD "
83
- echo " DB_SCHEMA_PASSWORD=$DB_SCHEMA_PASSWORD "
84
- echo " DB_USERNAME=$DB_USERNAME "
85
- echo " DOMAIN_HOME: $DOMAIN_HOME "
86
81
87
82
88
83
# Create an Infrastructure domain
89
84
# set environments needed for the script to work
90
85
ADD_DOMAIN=1
91
- export MW_HOME=" /u01/oracle"
92
- export WL_HOME=" /u01/oracle/wlserver"
93
- export ADMIN_USER=" weblogic"
94
- export DOMAIN_ROOT=" /shared/domains"
95
- export DOMAIN_HOME=" ${DOMAIN_ROOT} /${DOMAIN_NAME} "
96
86
97
-
98
- echo " MW_HOME: $MW_HOME "
99
- echo " WL_HOME: $WL_HOME "
100
- echo " ADMIN_USER: $ADMIN_USER "
101
- echo " DOMAIN_ROOT: $DOMAIN_ROOT "
102
- echo " DOMAIN HOME: $DOMAIN_HOME "
103
-
104
- if [ ! -f ${DOMAIN_HOME} /servers/AdminServer/logs/AdminServer.log ]; then
87
+ if [ ! -f ${DOMAIN_HOME} /servers/${ADMIN_NAME} /logs/${ADMIN_NAME} .log ]; then
105
88
ADD_DOMAIN=0
106
89
fi
107
90
108
91
# Create Domain only if 1st execution
109
92
if [ $ADD_DOMAIN -eq 0 ];
110
93
then
94
+ echo " Creating Domain 1st execution"
95
+ mkdir -p $ORACLE_HOME /properties
96
+ # Create Domain only if 1st execution
97
+ SEC_PROPERTIES_FILE=/u01/weblogic/domain_security.properties
98
+
99
+ if [ ! -e " $SEC_PROPERTIES_FILE " ]; then
100
+ echo " A properties file with the username and password needs to be supplied."
101
+ exit
102
+ fi
103
+
104
+ # Get Username
105
+ USER=` awk ' {print $1}' $SEC_PROPERTIES_FILE | grep username | cut -d " =" -f2`
106
+ if [ -z " $USER " ]; then
107
+ echo " The domain username is blank. The Admin username must be set in the properties file."
108
+ exit
109
+ fi
110
+ # echo "Username: $USER"
111
+ # Get Password
112
+ PASS=` awk ' {print $1}' $SEC_PROPERTIES_FILE | grep password | cut -d " =" -f2`
113
+ if [ -z " $PASS " ]; then
114
+ echo " The domain password is blank. The Admin password must be set in the properties file."
115
+ exit
116
+ fi
117
+ # echo "Password: $PASS"
118
+ # Get Database Username
119
+ DB_USER=` awk ' {print $1}' $SEC_PROPERTIES_FILE | grep db_user | cut -d " =" -f2`
120
+ if [ -z " $DB_USER " ]; then
121
+ echo " The domain username is blank. The Admin username must be set in the properties file."
122
+ exit
123
+ fi
124
+ # echo "Database Username $DB_USER"
125
+ # Get Database Password
126
+ DB_PASS=` awk ' {print $1}' $SEC_PROPERTIES_FILE | grep db_pass | cut -d " =" -f2`
127
+ if [ -z " $DB_PASS " ]; then
128
+ echo " The domain password is blank. The Admin password must be set in the properties file."
129
+ exit
130
+ fi
131
+ # echo "Database Password $DB_PASS"
132
+ # Get databasse Schema Password
133
+ DB_SCHEMA_PASS=` awk ' {print $1}' $SEC_PROPERTIES_FILE | grep db_schema | cut -d " =" -f2`
134
+ if [ -z " $DB_SCHEMA_PASS " ]; then
135
+ echo " The databse schema password is blank. The database schema password must be set in the properties file."
136
+ exit
137
+ fi
138
+ # echo "Database Schema Password: $DB_SCHEMA_PASS"
139
+
140
+
141
+ # Only call RCU the first time we create the domain
142
+ if [ -e $CONTAINERCONFIG_DIR /RCU.$RCUPREFIX .suc ]
143
+ then
144
+ # RCU has already been executed successfully, no need to rerun
145
+ RUN_RCU=" false"
146
+ echo " SOA RCU has already been loaded.. skipping"
147
+ fi
148
+
149
+ if [ " $RUN_RCU " == " true" ]
150
+ then
151
+ # Set the password for RCU
152
+ echo -e ${DB_PASS} " \n" ${DB_SCHEMA_PASS} > /u01/oracle/pwd.txt
153
+ echo " Loading SOA RCU into database"
154
+ # Run the RCU to load the schemas into the database
155
+ /u01/oracle/oracle_common/bin/rcu -silent -createRepository -databaseType ORACLE -connectString ${CONNECTION_STRING} -dbUser ${DB_USER} -dbRole sysdba -useSamePasswordForAllSchemaUsers true -selectDependentsForComponents true -schemaPrefix ${RCUPREFIX} -component MDS -component MDS -component IAU -component IAU_APPEND -component IAU_VIEWER -component OPSS -component WLS -component STB -f < /u01/oracle/pwd.txt >> /u01/oracle/RCU.out
156
+ retval=$?
157
+
158
+ if [ $retval -ne 0 ];
159
+ then
160
+ echo " RCU has some error "
161
+ # RCU was already called once and schemas are in the database
162
+ # continue with Domain creation
163
+ grep -q " RCU-6016 The specified prefix already exists" " /u01/oracle/RCU.out"
164
+ if [ $? -eq 0 ] ; then
165
+ echo " RCU has already loaded schemas into the Database"
166
+ echo " RCU Ignore error"
167
+ else
168
+ echo " RCU Loading Failed.. Please check the RCU logs"
169
+ cat /u01/oracle/RCU.out
170
+ exit
171
+ fi
172
+ fi
173
+
174
+ # cleanup : remove the password file for security
175
+ rm -f " /u01/oracle/pwd.txt"
176
+ fi
177
+
178
+ echo " Domain Configuration Phase"
179
+ echo " =========================="
180
+
181
+ wlst.sh -skipWLSModuleScanning /u01/weblogic/createInfraDomain.py -oh ${ORACLE_HOME} -jh ${JAVA_HOME} -parent ${DOMAIN_ROOT} -name ${DOMAIN_NAME} -user ${USER} -password ${PASS} -rcuDb ${CONNECTION_STRING} -rcuPrefix ${RCUPREFIX} -rcuSchemaPwd ${DB_SCHEMA_PASS} -adminListenPort ${ADMIN_LISTEN_PORT} -adminName ${ADMIN_NAME} -adminPortEnabled ${ADMINISTRATION_PORT_ENABLED} -administrationPort ${ADMINISTRATION_PORT} -managedName ${MANAGED_NAME} -managedServerPort ${MANAGEDSERVER_PORT} -prodMode ${PRODUCTION_MODE}
111
182
112
- # Auto generate Oracle WebLogic Server admin password
113
- if [ -z ${ADMIN_PASSWORD} ]
114
- then
115
- # Auto generate Oracle WebLogic Server admin password
116
- ADMIN_PASSWORD=$( rand_pwd)
117
- echo " "
118
- echo " Oracle WebLogic Server Password Auto Generated :"
119
- echo " "
120
- echo " ----> 'weblogic' admin password: $ADMIN_PASSWORD "
121
- echo " "
122
- fi ;
123
-
124
- if [ -z ${DB_SCHEMA_PASSWORD} ]
125
- then
126
- # Auto generate Oracle Database Schema password
127
- temp_pwd=$( rand_pwd)
128
- # Password should not start with a number for database
129
- f_str=` echo $temp_pwd | cut -c1| tr [0-9] [A-Z]`
130
- s_str=` echo $temp_pwd | cut -c2-`
131
- DB_SCHEMA_PASSWORD=${f_str}${s_str}
132
- echo " "
133
- echo " Database Schema password Auto Generated :"
134
- echo " "
135
- echo " ----> Database schema password: $DB_SCHEMA_PASSWORD "
136
- echo " "
137
- fi ;
138
-
139
- export ADMIN_PASSWORD=$ADMIN_PASSWORD
140
- export DB_SCHEMA_PASSWORD=$DB_SCHEMA_PASSWORD
141
- # Only call RCU the first time we create the domain
142
- if [ -e $CONTAINERCONFIG_DIR /RCU.$RCUPREFIX .suc ]
143
- then
144
- # RCU has already been executed successfully, no need to rerun
145
- RUN_RCU=" false"
146
- echo " SOA RCU has already been loaded.. skipping"
147
- fi
148
-
149
- if [ " $RUN_RCU " == " true" ]
150
- then
151
- echo " Loading SOA RCU into database"
152
- # Run the RCU to load the schemas into the database
153
- /u01/oracle/oracle_common/bin/rcu -silent -createRepository -databaseType ORACLE -connectString $CONNECTION_STRING -dbUser $DB_USERNAME -dbRole sysdba -useSamePasswordForAllSchemaUsers true -selectDependentsForComponents true -schemaPrefix $RCUPREFIX -component MDS -component MDS -component IAU -component IAU_APPEND -component IAU_VIEWER -component OPSS -component WLS -component STB -f < /u01/oracle/pwd.txt >> /u01/oracle/RCU.out
154
183
retval=$?
155
184
185
+ echo " RetVal from Domain creation $retval "
186
+
156
187
if [ $retval -ne 0 ];
157
188
then
158
- echo " RCU has some error "
159
- # RCU was already called once and schemas are in the database
160
- # continue with Domain creation
161
- grep -q " RCU-6016 The specified prefix already exists" " /u01/oracle/RCU.out"
162
- if [ $? -eq 0 ] ; then
163
- echo " RCU has already loaded schemas into the Database"
164
- echo " RCU Ignore error"
165
- else
166
- echo " RCU Loading Failed.. Please check the RCU logs"
167
- exit
168
- fi
189
+ echo " Domain Creation Failed.. Please check the Domain Logs"
190
+ exit
169
191
fi
170
192
171
- # cleanup : remove the password file for security
172
- rm -f " /u01/oracle/pwd.txt"
173
- fi
174
-
175
- echo " Domain Configuration Phase"
176
- echo " =========================="
193
+ # Create the security file to start the server(s) without the password prompt
194
+ mkdir -p ${DOMAIN_HOME} /servers/${ADMIN_NAME} /security/
195
+ echo " username=${USER} " >> ${DOMAIN_HOME} /servers/${ADMIN_NAME} /security/boot.properties
196
+ echo " password=${PASS} " >> ${DOMAIN_HOME} /servers/${ADMIN_NAME} /security/boot.properties
177
197
178
- wlst.sh -skipWLSModuleScanning /u01/weblogic/createInfraDomain.py -oh $ORACLE_HOME -jh $JAVA_HOME -parent $DOMAIN_ROOT -name $DOMAIN_NAME -user $ADMIN_USER -password $ADMIN_PASSWORD -rcuDb $CONNECTION_STRING -rcuPrefix $RCUPREFIX -rcuSchemaPwd $DB_SCHEMA_PASSWORD
179
- retval= $?
198
+ ${DOMAIN_HOME} /bin/setDomainEnv.sh
199
+ fi
180
200
181
- echo " RetVal from Domain creation $retval "
201
+ # Set Java options
202
+ export JAVA_OPTIONS=${JAVA_OPTIONS}
203
+ echo " Java Options: ${JAVA_OPTIONS} "
182
204
183
- if [ $retval -ne 0 ];
184
- then
185
- echo " Domain Creation Failed.. Please check the Domain Logs"
186
- exit
187
- fi
205
+ echo " Starting the Admin Server"
206
+ echo " =========================="
188
207
189
- # Create the security file to start the server(s) without the password prompt
190
- mkdir -p ${DOMAIN_HOME} /servers/AdminServer/security/
191
- echo " username=weblogic" > ${DOMAIN_HOME} /servers/AdminServer/security/boot.properties
192
- echo " password=$ADMIN_PASSWORD " >> ${DOMAIN_HOME} /servers/AdminServer/security/boot.properties
193
-
194
- mkdir -p ${DOMAIN_HOME} /servers/infraserver1/security/
195
- echo " username=weblogic" > ${DOMAIN_HOME} /servers/infraserver1/security/boot.properties
196
- echo " password=" $ADMIN_PASSWORD >> ${DOMAIN_HOME} /servers/infraserver1/security/boot.properties
197
-
198
- ${DOMAIN_HOME} /bin/setDomainEnv.sh
199
- fi
208
+ # Start Admin Server and tail the logs
209
+ # ${DOMAIN_HOME}/startWebLogic.sh
210
+ # touch ${DOMAIN_HOME}/servers/${ADMIN_NAME}/logs/${ADMIN_NAME}.log
211
+ # tail -f ${DOMAIN_HOME}/servers/${ADMIN_NAME}/logs/${ADMIN_NAME}.log &
200
212
213
+ childPID=$!
214
+ wait $childPID
0 commit comments