forked from ccnet/CruiseControl.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateCCNetVDir.vbs
More file actions
143 lines (94 loc) · 4.96 KB
/
Copy pathcreateCCNetVDir.vbs
File metadata and controls
143 lines (94 loc) · 4.96 KB
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
Option Explicit
'Create the CCNet web dashboard's virtual directory
'Syntax: createCCNetVDir <dashboardInstallDir>
' Error codes:
' 2: no installation directory provided
' 3: ccnet virtual directory already exists
' 4: created, but not confirmed
' 5: Unable to set ASP.NET version
' 6: Unable to locate .NET framework
'Constants we use:
' Starting with CCNet 1.3, we are a .NET 2.0 application:
Dim DotNetFrameworkVersion: DotNetFrameworkVersion = "v2.0"
' We're going to create a "ccnet" virtual directory:
Dim vdirName: vdirName = "ccnet"
' We're going to create the virtual directory on web site : Default Web Site
Dim webSiteName: webSiteName = "Default Web Site"
'dedicated application pool for CruiseControl.Net
Dim AppPoolName: AppPoolName="CruiseControl.Net"
' Are we debugging this script?
Dim DEBUG: DEBUG = false
createVDir()
'good site with documentation about appcmd
'http://blogs.msdn.com/b/mikezh/archive/2012/04/23/iis-appcmd-quick-reference.aspx
' Create a virtual directory named vdirName on web site webSiteName using .NET version DotNetFrameworkVersion
Function CreateVDir()
If WScript.Arguments.Count < 1 Then
WScript.Echo "Installation directory for the CruiseControl.NET Web Dashboard not provided; cannot continue."
WScript.Quit 2
End If
Dim webdashboardInstallDir: webdashboardInstallDir = WScript.Arguments(0)
WScript.Echo "Checking whether there is an existing virtual directory with the name " & vdirName
If not DoesCCNetVDirExist(vdirName) Then
CreateCCNetVDir webdashboardInstallDir, webSiteName, vdirName
End If
SetASPNETVersion AppPoolName, DotNetFrameworkVersion, webSiteName, vdirName
' Confirm the creation
WScript.Echo "Confirming that the virtual directory " & vdirName & " was created..."
If not DoesCCNetVDirExist(vdirName) Then
WScript.Echo vdirName & " virtual directory creation failed."
WScript.Quit 4
End If
WScript.Echo "Virtual directory for CruiseControl.NET Web Dashboard created successfully."
End Function
' Check if the specified virtual directory exists on the specified web site
' Returns true if so, false if not.
Function DoesCCNetVDirExist(vdirName)
DoesCCNetVDirExist = False
dim iisDirs
iisDirs = getCommandOutput("cmd /c %systemroot%\system32\inetsrv\APPCMD list vdir")
iisDirs = lcase(iisDirs)
If DEBUG Then : WScript.Echo "[DEBUG] IIs dirs found : " & vbcrlf & iisDirs : End If
if instr(iisDirs,vdirName) > 0 then 'vbs is NOT zero based !
DoesCCNetVDirExist = true
end if
End Function
Sub CreateCCNetVDir(webdashboardInstallDir, webSiteName, vdirName)
dim result
dim command
WScript.Echo "Creating virtual directory for CruiseControl.NET Web Dashboard at " & webdashboardInstallDir
command = "%systemroot%\system32\inetsrv\APPCMD add app /site.name:" & chr(34) & webSiteName & chr(34) & " /path:/" & vdirName & " /physicalpath:" & chr(34) & webdashboardInstallDir & chr(34)
result = getCommandOutput("cmd /c " & command)
If DEBUG Then : WScript.Echo "[DEBUG] IIs app creation : " & vbcrlf & result : End If
End Sub
Sub SetASPNETVersion(AppPoolName, DotNetFrameworkVersion, webSiteName, vdirName)
dim appPools
dim result
dim command
WScript.Echo "Setting application pool for CruiseControl.NET Web Dashboard " & AppPoolName & " to frameworkversion : " & DotNetFrameworkVersion
appPools = getCommandOutput("cmd /c %systemroot%\system32\inetsrv\APPCMD list apppool")
appPools = lcase(appPools)
If DEBUG Then : WScript.Echo "[DEBUG] IIs app pools found : " & vbcrlf & appPools : End If
if instr(appPools,lcase(AppPoolName)) = 0 then 'vbs is NOT zero based !
WScript.Echo " * Creating application pool for CruiseControl.NET Web Dashboard " & AppPoolName & " frameworkversion : " & DotNetFrameworkVersion
command = "%systemroot%\system32\inetsrv\APPCMD ADD apppool /name:" & chr(34) & AppPoolName & chr(34) & " /managedRuntimeVersion:" & DotNetFrameworkVersion
result = getCommandOutput("cmd /c " & command)
If DEBUG Then : WScript.Echo "[DEBUG] IIs app creation : " & vbcrlf & result : End If
end if
command = "%systemroot%\system32\inetsrv\APPCMD set apppool " & chr(34) & AppPoolName & chr(34) & " /managedRuntimeVersion:" & DotNetFrameworkVersion
result = getCommandOutput("cmd /c " & command)
If DEBUG Then : WScript.Echo "[DEBUG] update app pool framework version : " & vbcrlf & result : End If
command = "%systemroot%\system32\inetsrv\APPCMD set app " & chr(34) & webSiteName & "/" & vdirName & chr(34) & " /applicationpool:" & AppPoolName
result = getCommandOutput("cmd /c " & command)
If DEBUG Then : WScript.Echo "[DEBUG] IIs app set apppool : " & vbcrlf & result : End If
End Sub
'
' Capture the results of a command line execution and
' return them to the caller.
'
Function getCommandOutput(theCommand)
Dim objShell, objCmdExec
Set objShell = CreateObject("WScript.Shell")
Set objCmdExec = objshell.exec(thecommand)
getCommandOutput = objCmdExec.StdOut.ReadAll
end Function