Welcome, guest | Sign In | My Account | Store | Cart

WSAdmin JACL script to install and set properties for an application server running under WAS 5.1 base installation.

Called by a Windows bat file.

@echo off

set server=YourServer

echo ################################################### echo # Install %server% on %COMPUTERNAME% echo ###################################################

command.com /c

call wsadmin -username yourname^ -password yourpassword^ -f C:\scripts\websphere\JACL\installServer.tcl %server%

Tcl, 422 lines
  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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# 
# Install Application Server.
#
####################################################################
# Patrick Finnegan 26/08/2004.  V1. 
####################################################################

####################################################################
# List installed application servers.
####################################################################
proc showList { a } {

    puts "\nList installed servers"
    puts "\**********************\n"

    foreach e $a {
	regexp {(.*)(\(cells.*)} $e 1 2 3
	puts [ format "%-5s %-50s"  " "  $2 ]
#	puts [ format "%-10s %-50s\n" " "  $3 ]
	lappend returnList                 $2
    }

    return $returnList   
}
####################################################################
# Install Server then create properties for server.
####################################################################
proc installServer { serverName nodeId } {

   global AdminConfig 

   set nameList [ list name $serverName ]
   set attrList [ list $nameList        ] 

   if { [ catch {$AdminConfig create Server $nodeId $attrList} r ] == 0 } {
        puts "************************************"
        puts "$serverName server created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create $serverName server\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   set serverId [ $AdminConfig getid /Server:$serverName/ ]

   regexp {(.*)(\(cells.*)} $serverId 1 2 3
   set serverName $2

#  set Transaction Service Properties. 

   if { [ catch { setTransProps $serverId $serverName } r ] != 0 } {
	   return -code error $r
   }

#  set Web Container Properties. 

   if { [ catch { setWebProps $serverId $serverName } r ] != 0 } {
	   return -code error $r
   }

#  set Log File Properties. 

   if { [ catch { setLogProps $serverId $serverName } r ] != 0 } {
	   return -code error $r
   }

#  set JVM Properties. 

   if { [ catch { setJVMProps $serverId $serverName } r ] != 0 } {
	   return -code error $r
   }

}
####################################################################
# Set transaction service properties.
####################################################################
proc setTransProps {serverId serverName } {

   global alias 
   global AdminConfig 

   # get Transaction Service id 

   set TransactionServiceId [ $AdminConfig list TransactionService $serverId ]

   set drive [lindex [file split [info script]] 0 ] 

   set clientInactivityTimeout  [ list clientInactivityTimeout  60  ]
   set totalTranLifetimeTimeout [ list totalTranLifetimeTimeout 180 ]
   set transactionLogDirectory  [ list transactionLogDirectory  " " ]

   set attrList  [ list $clientInactivityTimeout  \
                        $totalTranLifetimeTimeout \
                        $transactionLogDirectory  \
                 ]

   if { [ catch { $AdminConfig modify $TransactionServiceId $attrList } r ] == 0 } {
        puts "************************************"
        puts "$serverName transaction properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create transaction properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }
}
####################################################################
# Set web container properties.
####################################################################
proc setWebProps {serverId serverName } {

   global AdminConfig 

   # get Web Container id 

   set WebContainerId [ $AdminConfig list WebContainer $serverId ]

   set defaultVirtualHostName [ list defaultVirtualHostName hbf0035_$serverName ] 
   set enableServletCaching   [ list enableServletCaching   true ] 

   set attrList [ list $defaultVirtualHostName \
                       $enableServletCaching   \
                ]

   if { [ catch { $AdminConfig modify $WebContainerId $attrList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - WebContainer properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create WebContainer properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   # get ThreadPool id 

   set threadPoolId [ lindex [ $AdminConfig list ThreadPool $WebContainerId ] 0 ]

   set inactivityTimeout  [ list inactivityTimeout 3500  ]
   set isGrowable         [ list isGrowable        true  ]
   set maximumSize        [ list maximumSize       50 ]
   set minimumSize        [ list minimumSize       10 ]

   set threadPoolList  [ list $inactivityTimeout   \
                              $isGrowable          \
                              $maximumSize         \
                              $minimumSize         \
                       ]

   if { [ catch { $AdminConfig modify $threadPoolId $threadPoolList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - Threadpool properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Threadpool properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   # get Session Manager id 

   set sessionManagerId [ $AdminConfig list SessionManager $WebContainerId]

   set accessSessionOnTimeout        [ list accessSessionOnTimeout        true   ]
   set allowSerializedSessionAccess  [ list allowSerializedSessionAccess  false  ] 
   set enable                        [ list enable                        true   ]
   set enableCookies                 [ list enableCookies                 true   ]
   set enableProtocolSwitchRewriting [ list enableProtocolSwitchRewriting false  ]
   set enableSSLTracking             [ list enableSSLTracking             false  ]
   set enableSecurityIntegration     [ list enableSecurityIntegration     true   ]
   set enableUrlRewriting            [ list enableUrlRewriting            false  ]
   set maxWaitTime                   [ list maxWaitTime                   5      ]

   set sessionManagerList [ list $accessSessionOnTimeout        \
                                 $allowSerializedSessionAccess  \
                                 $enable                        \
                                 $enableCookies                 \
                                 $enableProtocolSwitchRewriting \
                                 $enableSSLTracking             \
                                 $enableSecurityIntegration     \
                                 $enableUrlRewriting            \
                                 $maxWaitTime                   \
                          ]

   if { [ catch { $AdminConfig modify $sessionManagerId $sessionManagerList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - Session Manager properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Session Manager properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   # get Tuning Parms 

   set tuningParamsId [ $AdminConfig list TuningParams $WebContainerId ]

   set allowOverflow                 [ list allowOverflow           false ]
   set invalidationTimeout           [ list invalidationTimeout       30  ] 
   set maxInMemorySessionCount       [ list maxInMemorySessionCount 1000  ]

   set tuningParamsList [ list $allowOverflow           \
                               $invalidationTimeout     \
                               $maxInMemorySessionCount \
                       ]

   if { [ catch { $AdminConfig modify $tuningParamsId $tuningParamsList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - Tuning properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Tuning properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }
}
####################################################################
# Set logging properties.
####################################################################
proc setLogProps {serverId serverName } {

   global AdminConfig 

   # get websphere install directory from node variable map. 

   set nodeVarMapId [ $AdminConfig getid /Node:[exec hostname]/VariableMap:/ ]
   set listVar1     [ eval join  [ $AdminConfig showall $nodeVarMapId ] ]
   set x            [ lindex [ lindex $listVar1 [lsearch $listVar1 *WAS_INSTALL_ROOT*] ] 2 ]
   set WAS_INSTALL_ROOT [ lindex [ split $x ] 1 ]

   # get output log id 

   set outputLogId [ $AdminConfig showAttribute $serverId outputStreamRedirect ]

   set baseHour               [ list baseHour 24 ]
   set fileName               [ list fileName $WAS_INSTALL_ROOT\\logs\\$serverName\\$serverName\_SystemOut.log ]
   set formatWrites           [ list formatWrites           true   ]
   set maxNumberOfBackupFiles [ list maxNumberOfBackupFiles 5      ]
   set messageFormatKind      [ list messageFormatKind      BASIC  ]
   set rolloverPeriod         [ list rolloverPeriod         24     ]
   set rolloverSize           [ list rolloverSize           5      ]
   set rolloverType           [ list rolloverType           TIME   ]
   set suppressStackTrace     [ list suppressStackTrace     false  ]
   set suppressWrites         [ list suppressWrites         false  ]

   set attrList [ list $baseHour               \
                       $fileName               \
                       $formatWrites           \
                       $maxNumberOfBackupFiles \
                       $messageFormatKind      \
                       $rolloverPeriod         \
                       $rolloverSize           \
                       $rolloverType           \
                       $suppressStackTrace     \
                       $suppressWrites         \
                ]
   
   if { [ catch { $AdminConfig modify $outputLogId $attrList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - Server output log properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Server output log properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   # get error log id 

   set errorLogId [ $AdminConfig showAttribute $serverId errorStreamRedirect ]

   set baseHour               [ list baseHour 24 ]
   set fileName               [ list fileName $WAS_INSTALL_ROOT\\logs\\$serverName\\$serverName\_SystemErr.log ]
   set formatWrites           [ list formatWrites           true   ]
   set maxNumberOfBackupFiles [ list maxNumberOfBackupFiles 5      ]
   set messageFormatKind      [ list messageFormatKind      BASIC  ]
   set rolloverPeriod         [ list rolloverPeriod         24     ]
   set rolloverSize           [ list rolloverSize           5      ]
   set rolloverType           [ list rolloverType           TIME   ]
   set suppressStackTrace     [ list suppressStackTrace     false  ]
   set suppressWrites         [ list suppressWrites         false  ]

   set attrList [ list $baseHour               \
                       $fileName               \
                       $formatWrites           \
                       $maxNumberOfBackupFiles \
                       $messageFormatKind      \
                       $rolloverPeriod         \
                       $rolloverSize           \
                       $rolloverType           \
                       $suppressStackTrace     \
                       $suppressWrites         \
                ]

   if { [ catch { $AdminConfig modify $errorLogId $attrList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - Server error log properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Server error log properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

}
####################################################################
# Set JVM Properties.
####################################################################
proc setJVMProps {serverId serverName } {

   global AdminConfig 

   # get JVM id 

   set jvmId [ $AdminConfig list JavaVirtualMachine $serverId ]


   set initialHeapSize        [ list initialHeapSize 256 ]
   set maximumHeapSize        [ list maximumHeapSize 256 ]

   # set custom properties.
   ## ws.ext.dirs
  
   set name                   [ list name        ws.ext.dirs                  ]
   set value                  [ list value       {C:\HBFserver_properties  }  ]
   set description            [ list description {Application Property Files} ]

   set wsExtDirs              [ list $name $value $description ]

   ## classloader mode

   set name                   [ list name  {com.ibm.ws.classloader.J2EEApplicationMode} ]
   set value                  [ list value true ]
   set description            [ list description {classloader mode} ]

   set classLoaderMode        [ list $name $value $description ]

   set systemPropertiesList   [ list systemProperties [ list $classLoaderMode $wsExtDirs]]

   set attrList [ list $initialHeapSize        \
                       $maximumHeapSize        \
                       $systemPropertiesList   \
                ]

   if { [ catch { $AdminConfig modify $jvmId $attrList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - JVM properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Server JVM properties for $serverName\n"
           puts "************************************\n"
	   return -code error $r
   }

}

####################################################################
# Main Control.
####################################################################

puts "\n argc = $argc \n"

if {$argc < 1} {
        return -code error "error - no arguments supplied.  Supply server name"
        puts "no arguments"
}

set serverName    [lindex $argv 0]
set nodeName      [ exec hostname ] 
set nodeId        [ $AdminConfig getid /Node:$nodeName/ ]

#######################################################################
# List servers and check if target server already exists.
# If so delete it and recreate
#######################################################################

set servers [ $AdminConfig list Server ]

catch { showList $servers } r

catch {lsearch $r $serverName } r 

if { $r == -1 } {
    set continue true 
} else { 
        set serverId [ $AdminConfig getid /Server:$serverName/ ]
        catch { $AdminConfig remove $serverId } r
	puts $r
}
####################################################################
# Install Server 
####################################################################

if { [ catch { installServer $serverName $nodeId } r ] == 0 } {
    puts "************************************"
    puts "$serverName installed successfully"
    puts "************************************\n"
    puts "\n###### Admin Config Save ######\n"
    $AdminConfig save
} else {
        puts "\n$serverName failed to install\n"
        puts $r 
        puts "************************************\n"
}

####################################################################
# List servers to verify install 
####################################################################

set servers [ $AdminConfig list Server ]

catch { showList $servers } r

Automates server installation for repeat installs across several servers.

Created by Patrick Finnegan on Tue, 31 Aug 2004 (MIT)
Tcl recipes (162)
Patrick Finnegan's recipes (56)

Required Modules

  • (none specified)

Other Information and Tasks