-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscratch.sh
322 lines (280 loc) · 8.87 KB
/
scratch.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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
#!/bin/bash
#
# wlsndm startup script for node manager
#
# chkconfig: - 75 15
# description: weblogic
# processname: WLSADMIN
# Source function library
. /etc/rc.d/init.d/functions
set +x
[[ ! -z $2 ]] && PRC=`echo "$2"`|| PRC="ALL"
[[ ! -z $DOMAIN_HOME ]] && export BIN=$DOMAIN_HOME/bin || {
echo "`date` DOMAIN_HOME is not set. Please set the environment first.";
exit 1;
}
## nohup to start weblogic instances
NOHUP=`which nohup`;
## tee for logfile output
TEE=`which tee`;
## Wait Timeout for ADMIN Server Start
SLEEP=10;
## Port on which Weblogic Admin Server listens on (Default for HTTP: 9001)
WLS_ADMIN_PORT=`cat $DOMAIN_HOME/config/config.xml|grep -v grep|grep administration-port|tail -1|cut -d\> -f2| cut -d\< -f1`
[[ ! -z $WLS_ADMIN_PORT ]] || WLS_ADMIN_PORT=9001;
## Port on which Oracle HTTP Server listens on (Default for HTTP: 7777)
OHS_PORT=`cat $ORACLE_BASE/config/domains/meinestadt/config/fmwconfig/components/OHS/ohs/httpd.conf | egrep ^Listen|cut -d\ -f2`
[[ ! -z $OHS_PORT ]] || OHS_PORT=7777;
## This Script
prog=`basename $0`;
## This Logfile
LOG=$BIN/FORMS12_StartStop.log
################################################################################
# Helper Functions
usage() {
echo "Usage: $prog {start [service] | stop [service] | status [service] | help}"
}
check_result() {
if [ ! -z ${1} ]
then
[[ ${1} -eq 0 ]] && echo "OK" || echo "ERROR [Code: ${1}]";
else
echo && echo "`date` *** ERROR: Null Returncode ***"
fi
}
check_status() {
if ([ ! -z ${1} ] && [ ! -z ${2} ])
then
if [ ${1} -gt 0 ]
then
echo "`date` ${2} is running with ${1} process"
else
echo "`date` ${2} is not running! -1"
fi
else
echo "`date` *** ERROR: Missing mandatory parameter to check status 1: [$1] , 2: [$2] ***"
fi
}
################################################################################
### Setting Process Status Variables (should return at least 1 for each process)
WLADM=`ps -ef|grep -v grep| grep java|grep Dweblogic\.Name\=AdminServer|wc -l` >/dev/null;
WLFRM=`ps -ef|grep -v grep| grep java|grep WLS_FORMS|wc -l` >/dev/null;
WLREP=`ps -ef|grep -v grep| grep java|grep WLS_REPORTS|wc -l` >/dev/null;
WLNM=`ps -ef|grep -v grep| grep java|grep nodemanager|wc -l` >/dev/null;
REPS=`ps -ef|grep -v grep| grep java|grep Dcomponent.name=repsrv1|wc -l` >/dev/null;
OHS=`netstat -natp 2>/dev/null |grep -v grep|grep $OHS_PORT|grep LISTEN|wc -l` >/dev/null;
### Weblogic Admin Server (needs to be fully started, so check LISTEN Port)
WLADMS=`netstat -natp 2>/dev/null|grep ::1:${WLS_ADMIN_PORT}|grep LISTEN|grep -v grep|wc -l` >/dev/null;
################################################################################
## Process Arrays
WLS_PROCS=($WLNM $WLADM $WLFRM $WLREP $REPS $OHS);
WLS_PROC_NAMES=('WLNM' 'WLS_ADMIN' 'WLS_FORMS' 'WLS_REPORTS' 'REPS' 'OHS');
################################################################################
### Process Start Commands
## Generic Call
start_PROCESS() {
START_CMD="start_${1}";
[[ ${2} -eq 0 ]] && {
echo -n "`date` Starting ${1}..." | ${TEE} -a ${LOG}
${START_CMD} && RET=`echo $?` && sleep $SLEEP
check_result ${RET} | ${TEE} -a ${LOG};
} || {
echo "`date` ${1} is RUNNING already! Need to stop it first." | ${TEE} -a ${LOG}
#$0 status ${1};
}
}
start_WLS_NODEMANAGER() {
# Forms Nodemanager
$NOHUP $BIN/startNodeManager.sh > \
$DOMAIN_HOME/nodemanager/nodemanager.nohup.out \
2> $DOMAIN_HOME/nodemanager/nodemanager.nohup.err &
}
start_WLSADMIN() {
# Admin Server
$NOHUP $BIN/startWebLogic.sh > \
$DOMAIN_HOME/servers/AdminServer/logs/AdminServer.nohup.out \
2> $DOMAIN_HOME/servers/AdminServer/logs/AdminServer.nohup.err &
while !($WLADMS -gt 0) 2>/dev/null
do
echo "`date` *** Waiting for Weblogic Admin Server to Start ***"
sleep $SLEEP
done
}
start_WLS_FORMS() {
# Forms Weblogic Forms Server
$NOHUP $BIN/startManagedWebLogic.sh WLS_FORMS > \
$DOMAIN_HOME/servers/WLS_FORMS/logs/WLS_FORMS.nohup.out \
2> $DOMAIN_HOME/servers/WLS_REPORTS/logs/WLS_REPORTS.nohup.err &
}
start_WLS_REPORTS() {
# Forms Weblogic Reports Server
$NOHUP $BIN/startManagedWebLogic.sh WLS_REPORTS > \
$DOMAIN_HOME/servers/WLS_REPORTS/logs/WLS_REPORTS.nohup.out \
2> $DOMAIN_HOME/servers/WLS_REPORTS/logs/WLS_REPORTS.nohup.err &
}
start_REPS() {
# Report Server
$BIN/startComponent.sh repsrv1 > $BIN/repsrv1.log
}
start_OHS() {
# Oracle HTTP Server
$BIN/startComponent.sh ohs > $BIN/ohs.log
}
################################################################################
### Process Stop Commands
## Generic Call
stop_PROCESS() {
STOP_CMD="stop_${1}";
[[ ${2} -gt 0 ]] && {
echo -n $"`date` Stopping ${1}..." | ${TEE} -a ${LOG}
${STOP_CMD} && RET=`echo $?` && sleep $SLEEP
check_result ${RET} | ${TEE} -a ${LOG}
} || {
echo "`date` ${1} is not RUNNING! Need to start it first." | ${TEE} -a ${LOG}
#${0} status ${1};
}
}
stop_WLS_NODEMANAGER() {
# Forms Nodemanager
$BIN/stopNodeManager.sh >> \
$DOMAIN_HOME/nodemanager/nodemanager.nohup.out \
2>> $DOMAIN_HOME/nodemanager/nodemanager.nohup.err &
}
stop_WLSADMIN() {
# Admin Server
$BIN/stopWebLogic.sh >> \
$DOMAIN_HOME/servers/AdminServer/logs/AdminServer.nohup.out \
2>> $DOMAIN_HOME/servers/AdminServer/logs/AdminServer.nohup.err &
}
stop_WLS_FORMS() {
# Forms Weblogic Forms Server
$BIN/stopManagedWebLogic.sh WLS_FORMS >> \
$DOMAIN_HOME/servers/WLS_FORMS/logs/WLS_FORMS.nohup.out \
2>> $DOMAIN_HOME/servers/WLS_REPORTS/logs/WLS_REPORTS.nohup.err &
}
stop_WLS_REPORTS() {
# Forms Weblogic Reports Server
$BIN/stopManagedWebLogic.sh WLS_REPORTS >> \
$DOMAIN_HOME/servers/WLS_REPORTS/logs/WLS_REPORTS.nohup.out \
2>> $DOMAIN_HOME/servers/WLS_REPORTS/logs/WLS_REPORTS.nohup.err &
}
stop_REPS() {
# Report Server
$BIN/stopComponent.sh repsrv1 >> $BIN/repsrv1.log
}
stop_OHS() {
# Oracle HTTP Server
$BIN/stopComponent.sh ohs >> $BIN/ohs.log
}
################################################################################
### Main Commands
## Start
start() {
case "$PRC" in
"ALL" | "")
let a=0;
for p in ${WLS_PROC_NAMES[@]}; do
## get process status
x=${WLS_PROCS[${a}]};
start_PROCESS ${p} ${x}
let a=a+1;
done
;;
*)
let a=0;
for p in ${WLS_PROC_NAMES[@]}; do
## check if arg1 is in process list
if [ ${PRC} == ${p} ]
then
## get process status
x=${WLS_PROCS[${a}]};
start_PROCESS ${p} ${x}
fi
let a=a+1;
done
[[ ${a} -eq 0 ]] && echo "`date` *** Invalid Process ${PRC}!"
;;
esac
}
## Stop
stop() {
case "$PRC" in
"ALL" | "")
let a=0;
for p in ${WLS_PROC_NAMES[@]}; do
### get process status
x=${WLS_PROCS[${a}]};
stop_PROCESS ${p} ${x}
let a=a+1;
done
;;
*)
let a=0;
for p in ${WLS_PROC_NAMES[@]}; do
## check if arg1 is in process list
if [ ${PRC} == ${p} ]
then
## get current status for process
x=${WLS_PROCS[${a}]};
stop_PROCESS ${p} ${x}
fi
let a=a+1;
done
[[ ${a} -eq 0 ]] && echo "`date` *** Invalid Process ${PRC}!"
;;
esac
}
## Status
status() {
case "${PRC}" in
"ALL" | "")
let a=0;
for p in ${WLS_PROC_NAMES[@]}; do
## get current status for process
x=${WLS_PROCS[${a}]};
check_status ${x} ${p}
let a=a+1;
done
;;
*)
let a=0;
for p in ${WLS_PROC_NAMES[@]}; do
## check if arg1 is in process list
if [ ${PRC} == ${p} ]
then
## get current status for process
x=${WLS_PROCS[${a}]};
check_status ${x} ${p}
fi
let a=a+1;
done
[[ ${a} -eq 0 ]] && echo "`date` *** Invalid Process ${PRC}!"
;;
esac
}
###############################################################################
## Script Call
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
help)
echo "" && usage
echo "" && echo "Where service is one of the following:" && echo ""
for i in ${WLS_PROC_NAMES[@]}; do
echo $i
done
echo "" && echo "If no service is provided then ALL services are started/stopped" && echo ""
;;
*)
usage
exit 1
;;
esac
exit $?