-
Notifications
You must be signed in to change notification settings - Fork 0
/
pluginutil.sh
executable file
·139 lines (118 loc) · 4.17 KB
/
pluginutil.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
#!/bin/bash
# Wrapper to invoke the PluginCfgGenerator mbean from a dmgr to generate plugin-cfg.xml, propagate plugin-cfg.xml,
# and propagate plugin-key.kdb
# This script must live in $WAS_HOME/bin
binDir=`dirname $0`
. $binDir/setupCmdLine.sh
if [ $# -lt 1 ]; then
echo "$0 list [ ... wsadmin args ]"
echo "$0 generate|propagate|propagateKeyring webserver-name webserver-node-name [ ... wsadmin args ]"
echo "$0 ping|stop|start|restart webserver-name webserver-node-name [ ... wsadmin args ]"
exit 1
fi
OP=$1
if [ $OP = "list" ]; then
(${WAS_HOME}/bin/wsadmin.sh -lang jython -conntype NONE "$@" | sed -e 's/wsadmin>//')<<ENDHEREDOC1
print ""
print AdminTask.listServers('[-serverType WEB_SERVER ]')
ENDHEREDOC1
exit
fi
if [ $# -lt 3 ]; then
echo "$0 list [ ... wsadmin args ]"
echo "$0 generate|propagate|propagateKeyring webserver-name webserver-node-name [ ... wsadmin args ]"
echo "$0 ping|stop|start|restart webserver-name webserver-node-name [ ... wsadmin args ]"
exit 1
fi
WEBSERVER=$2
NODE=$3
shift 3
# Check that the user didn't need to pass credentials as supplicant args, e.g. no soap.client.props
if [[ ! $@ == *'-password'* ]]; then
echo "Checking wsadmin access"
echo "print ''" | ${WAS_HOME}/bin/wsadmin.sh -lang jython "$@" | grep WASX7246E > /dev/null
if [ $? -eq 0 ]; then
echo "$0 You must setup soap.client.props or pass -user ... -password ... to this command"
exit 1
fi
fi
echo "Requesting mbean op: $OP"
case $OP in
ping|stop|start)
(${WAS_HOME}/bin/wsadmin.sh -lang jython "$@" | sed -e 's/wsadmin>//g') <<ENDHEREDOC
mbean = AdminControl.queryNames("WebSphere:*,process=dmgr,type=WebServer")
args = '[$WAS_CELL $NODE $WEBSERVER]'
print AdminControl.invoke(mbean, '$OP', args)
ENDHEREDOC
;;
restart)
cat > /tmp/debug.out <<ENDHEREDOC
import time
mbean = AdminControl.queryNames("WebSphere:*,process=dmgr,type=WebServer")
args = '[$WAS_CELL $NODE $WEBSERVER]'
status = AdminControl.invoke(mbean, 'ping', args)
print "$WEBSERVER is %s" % (status)
if status == "RUNNING":
print "Stopping $WEBSERVER"
AdminControl.invoke(mbean, 'stop', args)
print "Waiting for $WEBSERVER to stop"
for i in range(10):
if status == "STOPPED":
print "$WEBSERVER is stopped"
break
status = AdminControl.invoke(mbean, 'ping', args)
sleep(i)
else:
print "Timed out stopping $WEBSERVER"
print "Starting $WEBSERVER"
AdminControl.invoke(mbean, 'start', args)
for i in range(10):
status = AdminControl.invoke(mbean, 'ping', args)
if status == "STARTED":
print "$WEBSERVER is started"
break
sleep(i)
else:
print "Timed out starting $WEBSERVER"
ENDHEREDOC
(${WAS_HOME}/bin/wsadmin.sh -lang jython "$@" | sed -e 's/wsadmin>//g') <<ENDHEREDOC
import time
mbean = AdminControl.queryNames("WebSphere:*,process=dmgr,type=WebServer")
args = '[$WAS_CELL $NODE $WEBSERVER]'
status = AdminControl.invoke(mbean, 'ping', args)
print "$WEBSERVER is %s" % (status)
if status == "RUNNING":
print "Stopping $WEBSERVER"
AdminControl.invoke(mbean, 'stop', args)
print "Waiting for $WEBSERVER to stop"
for i in range(10):
if status == "STOPPED":
print "$WEBSERVER is stopped"
break
status = AdminControl.invoke(mbean, 'ping', args)
sleep(i)
else:
print "Timed out stopping $WEBSERVER"
print "Starting $WEBSERVER"
AdminControl.invoke(mbean, 'start', args)
for i in range(10):
status = AdminControl.invoke(mbean, 'ping', args)
if status == "STARTED":
print "$WEBSERVER is started"
break
sleep(i)
else:
print "Timed out starting $WEBSERVER"
ENDHEREDOC
;;
*)
(${WAS_HOME}/bin/wsadmin.sh -lang jython "$@" | sed -e 's/wsadmin>//g') <<ENDHEREDOC
mbean = AdminControl.queryNames("WebSphere:*,process=dmgr,type=PluginCfgGenerator")
args = '[%s/config %s %s %s %s]' % ('$USER_INSTALL_ROOT', '$WAS_CELL', '$NODE', '$WEBSERVER', "false" if "$OP" == "generate" else "")
types = '[java.lang.String java.lang.String java.lang.String java.lang.String %s]' % ("java.lang.Boolean" if "$OP" == "generate" else "")
result = AdminControl.invoke(mbean, '$OP', args, types)
AdminConfig.save()
ENDHEREDOC
;;
esac
echo "Done"