~ubuntu-branches/ubuntu/oneiric/libapache-mod-jk/oneiric

« back to all changes in this revision

Viewing changes to jk/native/iis/isapi_install.vbs

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2006-08-05 16:30:53 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060805163053-myf66gm6j1a21ps6
Tags: 1:1.2.18-1ubuntu1
Merge from Debian unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
'
2
 
' Copyright 1999-2004 The Apache Software Foundation
3
 
'
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
7
 
'
8
 
'    http://www.apache.org/licenses/LICENSE-2.0
9
 
'
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.
15
 
'
16
 
 
17
 
' =========================================================================
18
 
' Description: Install script for Tomcat ISAPI redirector                              
19
 
' Author:      Peter S. Horne <horneps@yahoo.com.au>                           
20
 
' Version:     $Revision: 1.5 $                                           
21
 
' =========================================================================
22
 
'
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.
26
 
 
27
 
'
28
 
'  Check the command line
29
 
'
30
 
set args = wscript.arguments
31
 
if args.count <> 6 then 
32
 
        info ""
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)"
42
 
        info ""
43
 
        fail "Incorrect Arguments"
44
 
end if
45
 
 
46
 
' Setup the args
47
 
serverName = args(0)
48
 
filterDir = args(1)
49
 
filterName = "jakarta"
50
 
filterLib = "\isapi_redirect.dll"
51
 
workerFile = args(2)
52
 
mountFile = args(3)
53
 
logFile = args(4)
54
 
logLevel = args(5)
55
 
 
56
 
'
57
 
' Get a shell
58
 
'
59
 
dim shell
60
 
set shell = WScript.CreateObject("WScript.Shell")
61
 
 
62
 
'
63
 
' Find the indicated server from all the servers in the service 
64
 
' Note: they aren't all Web!
65
 
'
66
 
set service = GetObject("IIS://LocalHost/W3SVC" )
67
 
serverId = ""
68
 
for each thing in service
69
 
         if thing.Class = "IIsWebServer" then
70
 
                if thing.ServerComment = serverName then 
71
 
                        set server = thing
72
 
                        serverId = thing.name
73
 
                        exit for
74
 
                end if
75
 
        end if
76
 
next
77
 
if serverId = "" then fail "Server " + serverName + " not found."
78
 
info "Found Server <" + serverName + "> at index [" + serverId + "]."
79
 
 
80
 
'
81
 
' Stop everything to release any dlls - needed for a re-install
82
 
'
83
 
' info "Stopping server <" + serverName + ">..."
84
 
' server.stop
85
 
' info "Done"
86
 
 
87
 
'
88
 
' Get a handle to the filters for the server - we process all errors
89
 
'
90
 
On Error Resume Next
91
 
dim filters
92
 
set filters = GetObject("IIS://LocalHost/W3SVC/" + serverId + "/Filters")
93
 
if err then 
94
 
        err.clear
95
 
        info "Filters not found for server - creating"
96
 
        set filters = server.create( "IIsFilters", "Filters" )
97
 
        filters.setInfo
98
 
        if err then fail "Error Creating Filters"
99
 
end if
100
 
info "Got Filters"
101
 
 
102
 
'
103
 
' Create the filter - if it fails then delete it and try again
104
 
'
105
 
name = filterName
106
 
info "Creating Filter  - " + filterName
107
 
dim filter
108
 
set filter = filters.Create( "IISFilter", filterName )
109
 
if err then
110
 
        err.clear
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"
116
 
end if
117
 
info "Created Filter"
118
 
 
119
 
'
120
 
' Set the filter info and save it
121
 
'
122
 
filter.FilterPath = filterDir + filterLib  
123
 
filter.FilterEnabled=true
124
 
filter.description = filterName
125
 
filter.notifyOrderHigh = true
126
 
filter.setInfo
127
 
 
128
 
'
129
 
' Set the load order - only if it's not in the list already
130
 
'
131
 
on error goto 0
132
 
loadOrders = filters.FilterLoadOrder
133
 
list = Split( loadOrders, "," )
134
 
found = false
135
 
for each item in list
136
 
        if Trim( item ) = filterName then found = true
137
 
next
138
 
 
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
143
 
        filters.setInfo
144
 
        info "Filter added."
145
 
else
146
 
        info "Filter already exists in load order - no update required."
147
 
end if
148
 
 
149
 
'
150
 
' Set the registry up
151
 
152
 
regRoot = "HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0\"
153
 
err.clear
154
 
on error resume next
155
 
shell.RegDelete( regRoot )
156
 
if err then 
157
 
        info "Entering Registry Information for the first time"
158
 
else 
159
 
        info "Deleted existing Registry Setting"
160
 
end if
161
 
 
162
 
on error goto 0
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"
170
 
 
171
 
'
172
 
' Finally, create the virtual directory matching th extension uri
173
 
174
 
on error goto 0
175
 
set root = GetObject( "IIS://LocalHost/W3SVC/" + serverID + "/ROOT" )
176
 
on error resume next
177
 
set vdir = root.Create("IISWebVirtualDir", filterName )
178
 
if err then
179
 
        info "Directory exists - deleting"
180
 
        on error resume next
181
 
        root.delete "IISWebVirtualDir", filterName
182
 
        root.setInfo
183
 
        if err then fail "Error Deleting Directory"
184
 
        set vdir = root.create("IISWebVirtualDir", filterName )
185
 
        if err then fail "Error Creating Directory"
186
 
end if
187
 
info "Directory Created"
188
 
 
189
 
' Set the directory information - make it an application directory
190
 
info "Setting Directory Information"
191
 
vdir.AppCreate2 1
192
 
vdir.AccessExecute = TRUE
193
 
vdir.AppFriendlyName = filterName
194
 
vdir.AccessRead = false
195
 
vdir.ContentIndexed = false
196
 
vdir.Path = filterDir
197
 
vdir.setInfo
198
 
if err then fail "Error saving new directory"
199
 
info "Directory Saved"
200
 
'
201
 
' Re Start 
202
 
'
203
 
' info "Starting server <" + serverName + ">..."
204
 
' server.start
205
 
' info "Done"
206
 
 
207
 
info "All done... Bye."
208
 
wscript.quit(0)
209
 
 
210
 
211
 
' Helper function for snafus
212
 
'
213
 
function fail( message )
214
 
        wscript.echo "E: " + message
215
 
        wscript.quit(1)
216
 
end function
217
 
 
218
 
'
219
 
' Helper function for info
220
 
'
221
 
function info( message )
222
 
        wscript.echo " " + message
223
 
end function