2
' Copyright 1999-2004 The Apache Software Foundation
4
' Licensed under the Apache License, Version 2.0 (the "License");
5
' you may not use this file except in compliance with the License.
6
' You may obtain a copy of the License at
8
' http://www.apache.org/licenses/LICENSE-2.0
10
' Unless required by applicable law or agreed to in writing, software
11
' distributed under the License is distributed on an "AS IS" BASIS,
12
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
' See the License for the specific language governing permissions and
14
' limitations under the License.
17
' =========================================================================
18
' Description: Install script for Tomcat ISAPI redirector
19
' Author: Peter S. Horne <horneps@yahoo.com.au>
20
' Version: $Revision: 1.5 $
21
' =========================================================================
23
' This script automatically installs the tomcat isapi_redirector for use in
24
' both out-of and in-process installations on IIS/Win2K. See the command line
25
' usage section for usage instructions.
28
' Check the command line
30
set args = wscript.arguments
31
if args.count <> 6 then
33
info "Tomcat ISAPI Redirector Installation Utility"
34
info "usage: isapi_install <server> <fdir> <worker> <mount> <log> <level>"
35
info " server: The Web Server Name (for example 'Default Web Site')"
36
info " fdir: the full path to the directory that contains the isapi filter"
37
info " worker: Full path and file name of the worker properties file"
38
info " mount: Full path and file name of the worker mount properties file"
39
info " log: Full path and file name of the log file"
40
info " level: The log level emerg | info"
41
info "(Re-runs are ok and will change/reset settings)"
43
fail "Incorrect Arguments"
49
filterName = "jakarta"
50
filterLib = "\isapi_redirect.dll"
60
set shell = WScript.CreateObject("WScript.Shell")
63
' Find the indicated server from all the servers in the service
64
' Note: they aren't all Web!
66
set service = GetObject("IIS://LocalHost/W3SVC" )
68
for each thing in service
69
if thing.Class = "IIsWebServer" then
70
if thing.ServerComment = serverName then
77
if serverId = "" then fail "Server " + serverName + " not found."
78
info "Found Server <" + serverName + "> at index [" + serverId + "]."
81
' Stop everything to release any dlls - needed for a re-install
83
' info "Stopping server <" + serverName + ">..."
88
' Get a handle to the filters for the server - we process all errors
92
set filters = GetObject("IIS://LocalHost/W3SVC/" + serverId + "/Filters")
95
info "Filters not found for server - creating"
96
set filters = server.create( "IIsFilters", "Filters" )
98
if err then fail "Error Creating Filters"
103
' Create the filter - if it fails then delete it and try again
106
info "Creating Filter - " + filterName
108
set filter = filters.Create( "IISFilter", filterName )
111
info "Filter exists - deleting"
112
filters.delete "IISFilter", filterName
113
if err then fail "Error Deleting Filter"
114
set filter = filters.Create( "IISFilter", filterName )
115
if err then fail "Error Creating Filter"
117
info "Created Filter"
120
' Set the filter info and save it
122
filter.FilterPath = filterDir + filterLib
123
filter.FilterEnabled=true
124
filter.description = filterName
125
filter.notifyOrderHigh = true
129
' Set the load order - only if it's not in the list already
132
loadOrders = filters.FilterLoadOrder
133
list = Split( loadOrders, "," )
135
for each item in list
136
if Trim( item ) = filterName then found = true
139
if found = false then
140
info "Filter is not in load order - adding now."
141
if len(loadOrders) <> 0 then loadOrders = loadOrders + ","
142
filters.FilterLoadOrder = loadOrders + filterName
146
info "Filter already exists in load order - no update required."
150
' Set the registry up
152
regRoot = "HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0\"
155
shell.RegDelete( regRoot )
157
info "Entering Registry Information for the first time"
159
info "Deleted existing Registry Setting"
163
info "Updating Registry"
164
shell.RegWrite regRoot + "extension_uri", "/jakarta/isapi_redirect.dll"
165
shell.RegWrite regRoot + "log_file", logFile
166
shell.RegWrite regRoot + "log_level", logLevel
167
shell.RegWrite regRoot + "worker_file", workerFile
168
shell.RegWrite regRoot + "worker_mount_file", mountFile
169
info "Registry Settings Created"
172
' Finally, create the virtual directory matching th extension uri
175
set root = GetObject( "IIS://LocalHost/W3SVC/" + serverID + "/ROOT" )
177
set vdir = root.Create("IISWebVirtualDir", filterName )
179
info "Directory exists - deleting"
181
root.delete "IISWebVirtualDir", filterName
183
if err then fail "Error Deleting Directory"
184
set vdir = root.create("IISWebVirtualDir", filterName )
185
if err then fail "Error Creating Directory"
187
info "Directory Created"
189
' Set the directory information - make it an application directory
190
info "Setting Directory Information"
192
vdir.AccessExecute = TRUE
193
vdir.AppFriendlyName = filterName
194
vdir.AccessRead = false
195
vdir.ContentIndexed = false
196
vdir.Path = filterDir
198
if err then fail "Error saving new directory"
199
info "Directory Saved"
203
' info "Starting server <" + serverName + ">..."
207
info "All done... Bye."
211
' Helper function for snafus
213
function fail( message )
214
wscript.echo "E: " + message
219
' Helper function for info
221
function info( message )
222
wscript.echo " " + message