2 ' Licensed to the Apache Software Foundation (ASF) under one or more
3 ' contributor license agreements. See the NOTICE file distributed with
4 ' this work for additional information regarding copyright ownership.
5 ' The ASF licenses this file to You under the Apache License, Version 2.0
6 ' (the "License"); you may not use this file except in compliance with
7 ' the License. You may obtain a copy of the License at
9 ' http://www.apache.org/licenses/LICENSE-2.0
11 ' Unless required by applicable law or agreed to in writing, software
12 ' distributed under the License is distributed on an "AS IS" BASIS,
13 ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ' See the License for the specific language governing permissions and
15 ' limitations under the License.
18 ' =========================================================================
19 ' Description: Install script for Tomcat ISAPI redirector
20 ' Author: Peter S. Horne <horneps@yahoo.com.au>
21 ' Version: $Revision: 572120 $
22 ' =========================================================================
24 ' This script automatically installs the tomcat isapi_redirector for use in
25 ' both out-of and in-process installations on IIS/Win2K. See the command line
26 ' usage section for usage instructions.
29 ' Check the command line
31 set args = wscript.arguments
32 if args.count <> 6 then
34 info "Tomcat ISAPI Redirector Installation Utility"
35 info "usage: isapi_install <server> <fdir> <worker> <mount> <log> <level>"
36 info " server: The Web Server Name (for example 'Default Web Site')"
37 info " fdir: the full path to the directory that contains the isapi filter"
38 info " worker: Full path and file name of the worker properties file"
39 info " mount: Full path and file name of the worker mount properties file"
40 info " log: Full path and file name of the log file"
41 info " level: The log level emerg | info"
42 info "(Re-runs are ok and will change/reset settings)"
44 fail "Incorrect Arguments"
50 filterName = "jakarta"
51 filterLib = "\isapi_redirect.dll"
61 set shell = WScript.CreateObject("WScript.Shell")
64 ' Find the indicated server from all the servers in the service
65 ' Note: they aren't all Web!
67 set service = GetObject("IIS://LocalHost/W3SVC" )
69 for each thing in service
70 if thing.Class = "IIsWebServer" then
71 if thing.ServerComment = serverName then
78 if serverId = "" then fail "Server " + serverName + " not found."
79 info "Found Server <" + serverName + "> at index [" + serverId + "]."
82 ' Stop everything to release any dlls - needed for a re-install
84 ' info "Stopping server <" + serverName + ">..."
89 ' Get a handle to the filters for the server - we process all errors
93 set filters = GetObject("IIS://LocalHost/W3SVC/" + serverId + "/Filters")
96 info "Filters not found for server - creating"
97 set filters = server.create( "IIsFilters", "Filters" )
99 if err then fail "Error Creating Filters"
104 ' Create the filter - if it fails then delete it and try again
107 info "Creating Filter - " + filterName
109 set filter = filters.Create( "IISFilter", filterName )
112 info "Filter exists - deleting"
113 filters.delete "IISFilter", filterName
114 if err then fail "Error Deleting Filter"
115 set filter = filters.Create( "IISFilter", filterName )
116 if err then fail "Error Creating Filter"
118 info "Created Filter"
121 ' Set the filter info and save it
123 filter.FilterPath = filterDir + filterLib
124 filter.FilterEnabled=true
125 filter.description = filterName
126 filter.notifyOrderHigh = true
130 ' Set the load order - only if it's not in the list already
133 loadOrders = filters.FilterLoadOrder
134 list = Split( loadOrders, "," )
136 for each item in list
137 if Trim( item ) = filterName then found = true
140 if found = false then
141 info "Filter is not in load order - adding now."
142 if len(loadOrders) <> 0 then loadOrders = loadOrders + ","
143 filters.FilterLoadOrder = loadOrders + filterName
147 info "Filter already exists in load order - no update required."
151 ' Set the registry up
153 regRoot = "HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0\"
156 shell.RegDelete( regRoot )
158 info "Entering Registry Information for the first time"
160 info "Deleted existing Registry Setting"
164 info "Updating Registry"
165 shell.RegWrite regRoot + "extension_uri", "/jakarta/isapi_redirect.dll"
166 shell.RegWrite regRoot + "log_file", logFile
167 shell.RegWrite regRoot + "log_level", logLevel
168 shell.RegWrite regRoot + "worker_file", workerFile
169 shell.RegWrite regRoot + "worker_mount_file", mountFile
170 info "Registry Settings Created"
173 ' Finally, create the virtual directory matching th extension uri
176 set root = GetObject( "IIS://LocalHost/W3SVC/" + serverID + "/ROOT" )
178 set vdir = root.Create("IISWebVirtualDir", filterName )
180 info "Directory exists - deleting"
182 root.delete "IISWebVirtualDir", filterName
184 if err then fail "Error Deleting Directory"
185 set vdir = root.create("IISWebVirtualDir", filterName )
186 if err then fail "Error Creating Directory"
188 info "Directory Created"
190 ' Set the directory information - make it an application directory
191 info "Setting Directory Information"
193 vdir.AccessExecute = TRUE
194 vdir.AppFriendlyName = filterName
195 vdir.AccessRead = false
196 vdir.ContentIndexed = false
197 vdir.Path = filterDir
199 if err then fail "Error saving new directory"
200 info "Directory Saved"
204 ' info "Starting server <" + serverName + ">..."
208 info "All done... Bye."
212 ' Helper function for snafus
214 function fail( message )
215 wscript.echo "E: " + message
220 ' Helper function for info
222 function info( message )
223 wscript.echo " " + message