-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.ias_wcache
206 lines (176 loc) · 4.13 KB
/
init.ias_wcache
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
#!/bin/sh
# chkconfig: 345 99 01
# description: Service starts/stops iAS WebCache processes
# processname: init.ias_wcache
#
# Start/stop iAS WebCache services as part of system startup/shutdown procedure
# using SMF or traditional rcx.d scripts sequence (Solaris/Linux).
#
# Yuri Voinov (C) 2006-2010
# Thanks Joost Mulders (Sun Microsystems) for idea
# and initial implementation.
#
# ident "@(#)init.ias_wcache 2.5 10/11/01 YV"
#
#############
# Variables #
#############
#
# OS Commands location variables
#
AWK=`which awk`
BASENAME=`which basename`
CUT=`which cut`
ECHO=`which echo`
EGREP=`which egrep`
LS=`which ls`
PS=`which ps`
RM=`which rm`
SU=`which su`
TOUCH=`which touch`
UNAME=`which uname`
WHOAMI=`which whoami`
OS_NAME=`$UNAME -s|$CUT -f1 -d" "`
# Linux lock directory
LOCK_DIR="/var/lock/subsys"
# Script name for Linux up/down workaround
SVC_SHORT_NAME="wcache"
SCRIPT_NAME="init.ias_$SVC_SHORT_NAME"
# Config file directory. Default is /etc
CONFIG_DIR="/etc"
# Config file name.
CONFIG_FILE="$CONFIG_DIR/ias_$SVC_SHORT_NAME.conf"
###############
# Subroutines #
###############
get_config_parameters ()
{
# Check if config exists
if [ ! -f "$CONFIG_FILE" ]; then
$ECHO "Config file $CONFIG_FILE not found. Exiting..."
exit 1
else
# Load config file into environment
. $CONFIG_FILE
fi
}
check_oracle_and_get_uid ()
{
# Check if Oracle sfw installed and get UID if yes
orahome=$1
oramodule=$2
if [ -f "$orahome/bin/$oramodule" ]; then
ORACLE_UID=`$LS -l $orahome/bin/$oramodule | $AWK '{ print $3 }'`
else
$ECHO "$0: Oracle software not installed. Exiting..."
$ECHO "$0: Oracle software not installed. Exiting..." >> $LOG
exit 1
fi
}
iasconsole_ctl ()
# OEM iasconsole control function
{
cmd=$1
orahome=$2
$SU $ORACLE_UID -c "
ORACLE_HOME=$orahome
PATH=$orahome/bin:$PATH
LD_LIBRARY_PATH=$orahome/lib
export ORACLE_HOME LD_LIBRARY_PATH
\$ORACLE_HOME/bin/emctl $cmd iasconsole" >> $LOG
}
wcache_ctl ()
# WebCache control function
{
cmd=$1
orahome=$2
if [ -f $ORA_HOME/opmn/bin/opmnctl -a -n "$USEOPMN" ]; then
$SU $ORACLE_UID -c "
ORACLE_HOME=$orahome
PATH=$orahome/bin:$PATH
LD_LIBRARY_PATH=$orahome/lib
export ORACLE_HOME LD_LIBRARY_PATH
\$ORACLE_HOME/opmn/bin/opmnctl "$cmd"all
if [ "$cmd" = "stop" ]; then
\$ORACLE_HOME/opmn/bin/opmnctl status
fi
" >> $LOG
elif [ ! -f $ORA_HOME/opmn/bin/opmnctl -o -z "$USEOPMN" -a -f $ORA_HOME/webcache/bin/webcachectl ]; then
$SU $ORACLE_UID -c "
ORACLE_HOME=$orahome
PATH=$orahome/bin:$PATH
LD_LIBRARY_PATH=$orahome/lib
export ORACLE_HOME LD_LIBRARY_PATH
\$ORACLE_HOME/webcache/bin/webcachectl "$cmd"
if [ "$cmd" != "stop" ]; then
\$ORACLE_HOME/webcache/bin/webcachectl status
fi
" >> $LOG
else
$ECHO "WebCache not installed or ORA_HOME defined improperly."
$ECHO "WebCache not installed or ORA_HOME defined improperly." >> $LOG
exit 1
fi
}
##############
# Main block #
##############
# Set configuration parameters
get_config_parameters
# Check ORA_HOME
if [ -z "$ORA_HOME" ]; then
$ECHO "$0: ORA_HOME for WebCache not defined!"
$ECHO "Exiting..."
exit 1
fi
# Check oracle and get uid
check_oracle_and_get_uid "$ORA_HOME" "genclntsh"
case $1 in
stop)
CMDLIST=stop
;;
start)
CMDLIST=start
;;
restart)
CMDLIST="stop start"
;;
*)
$ECHO "usage $0 <[start|stop|restart>"
exit 1
;;
esac
for CMD in $CMDLIST
do
case $CMD in
start)
$ECHO "`date` Starting iAS WebCache..." >> $LOG
wcache_ctl start $ORA_HOME
if [ "$USEIASCTL" = "1" ]; then
iasconsole_ctl stop $ORA_HOME
iasconsole_ctl start $ORA_HOME
fi
$ECHO "`date` iAS WebCache started." >> $LOG
if [ "$OS_NAME" = "Linux" ]; then
# Linux up/down workaround
$TOUCH "$LOCK_DIR"/"$SCRIPT_NAME"
fi
;;
stop)
$ECHO "`date` Stopping iAS WebCache..." >> $LOG
if [ "$USEIASCTL" = "1" ]; then
iasconsole_ctl stop $ORA_HOME
fi
wcache_ctl stop $ORA_HOME
$ECHO "`date` iAS WebCache stopped." >> $LOG
if [ "$OS_NAME" = "Linux" ]; then
# Linux up/down workaround
$RM -f "$LOCK_DIR"/"$SCRIPT_NAME"
fi
;;
*)
$ECHO "usage `$BASENAME $0: <[stop|start|restart]>`"
exit 1
;;
esac
done