-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall-prereqs.ps1
191 lines (137 loc) · 5.46 KB
/
install-prereqs.ps1
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
require $JBOSS_ADDRESS "JBOSS_ADDRESS must be set"
require $JBOSS_PORT "JBOSS_PORT must be set"
require $JBOSS_ADMIN "JBOSS_ADMIN must be set"
require $JBOSS_PASS "JBOSS_PASS must be set"
#Install chocolatey https://chocolatey.org/
function installChocolatey{
if ((Get-Command choco) -eq $null){
echo "Installing Chocolatey"
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
}
}
#region Choco Functions...
function Get-EnvironmentVariable([string] $Name, [System.EnvironmentVariableTarget] $Scope) {
[Environment]::GetEnvironmentVariable($Name, $Scope)
}
function Get-EnvironmentVariableNames([System.EnvironmentVariableTarget] $Scope) {
switch ($Scope) {
'User' { Get-Item 'HKCU:\Environment' | Select-Object -ExpandProperty Property }
'Machine' { Get-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' | Select-Object -ExpandProperty Property }
'Process' { Get-ChildItem Env:\ | Select-Object -ExpandProperty Key }
default { throw "Unsupported environment scope: $Scope" }
}
}
function Update-SessionEnvironment{
Write-Debug "Running 'Update-SessionEnvironment' - Updating the environment variables for the session."
#ordering is important here, $user comes after so we can override $machine
'Machine', 'User' |
% {
$scope = $_
Get-EnvironmentVariableNames -Scope $scope |
% {
Set-Item "Env:$($_)" -Value (Get-EnvironmentVariable -Scope $scope -Name $_)
}
}
#Path gets special treatment b/c it munges the two together
$paths = 'Machine', 'User' |
% {
(Get-EnvironmentVariable -Name 'PATH' -Scope $_) -split ';'
} |
Select -Unique
$Env:PATH = $paths -join ';'
}
#endregion Choco Functions
function installJava{
echo "Installing Java"
choco install jdk7 -y -version 7.0.79
Update-SessionEnvironment
$java_home = Join-Path (Get-Item "Env:ProgramFiles").Value "Java\jdk1.7.0_79"
setEnvironmentVariable "JAVA_HOME" $java_home
echo "JAVA_HOME set to: $env:JAVA_HOME"
#$env:JAVA_HOME = $java_home
#echo "JAVA_HOME set (again) to: $env:JAVA_HOME"
if($env:JAVA_HOME -eq $null){
throw "JAVA_HOME not set"
}
echo "Java Installed"
}
function installAnt {
echo "Installing Ant"
choco install ant -yi
Update-SessionEnvironment
echo "ANT_HOME set to: $env:ANT_HOME"
addToPath $env:ANT_HOME\bin
echo "Ant Installed"
}
#Takes the boolean value $service for option to install tomcat service
#$service is true by default
function installTomcat($service=$true){
echo "Installing Tomcat"
choco install tomcat -y -i -version 7.0.59
Update-SessionEnvironment
echo "CATALINA_HOME set to: $env:CATALINA_HOME"
echo "Tomcat is installed."
}
function installJBoss{
echo "Installing JBoss"
#note: remove the source once the package is approved
choco install jboss-as -yi -params "/InstallationPath:$__jbossInstallFolder /Username:$JBOSS_ADMIN /Password:$JBOSS_PASS /Start:false" -source $__skelDirectory
Update-SessionEnvironment
echo "JBOSS_HOME set to: $env:JBOSS_HOME"
if($env:JBOSS_HOME -ne $__jbossInstallFolder){
throw "JBOSS_HOME not set"
}
mv -force $env:JBOSS_HOME\standalone\configuration\standalone.xml $env:JBOSS_HOME\standalone\configuration\standalone.xml.bak
interpolate_file skel\jboss\standalone.xml JBOSS_ADDRESS $JBOSS_ADDRESS |
interpolate JBOSS_PORT $JBOSS_PORT |
Out-File -Encoding utf8 $env:JBOSS_HOME\standalone\configuration\standalone.xml
echo "JBoss Installed"
}
function installAxis{
echo "Installing AXIS War"
#note: remove the source once the package is approved
choco install axis2-war -iy -version 1.6.1 -params "/InstallationPath: $env:JBOSS_HOME\standalone\deployments\i2b2.war" -source $__skelDirectory
echo "" > $env:JBOSS_HOME\standalone\deployments\i2b2.war.dodeploy
echo "AXIS War Installed"
}
function installIIS {
echo "Installing IIS"
$iis = Get-WindowsOptionalFeature -FeatureName IIS-WebServerRole -Online
if($iis.State -ne "Enabled"){
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole -NoRestart
}
echo "IIS Installed"
}
function installPHP{
echo "Installing PHP"
choco install vcredist2012 -y #need vc++ redist package
choco install php -y
cp $__skelDirectory\php\php.ini "c:\tools\php\php.ini" -force #enable curl
echo "Configuring IIS"
#enable required IIS freatures
#$cgi = Get-WindowsOptionalFeature -FeatureName IIS-CGI -Online
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CGI -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIExtensions -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIFilter -NoRestart
#Reference: http://php.net/manual/en/install.windows.iis7.php
#Creating IIS FastCGI process pool
& $env:WinDir\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='c:\tools\php\php-cgi.exe']" /commit:apphost
#Creating handler mapping for PHP requests
& $env:WinDir\system32\inetsrv\appcmd.exe set config -section:system.webServer/handlers /+"[name='PHP-FastCGI',path='*.php',verb='GET,HEAD,POST',modules='FastCgiModule',scriptProcessor='c:\tools\php\php-cgi.exe',resourceType='Either']"
echo "IIS Configured"
echo "PHP Installed"
}
installChocolatey
installJava
installAnt
if($InstallCells -eq $true){
installJBoss
installAxis
}
if(($InstallWebClient -eq $true) -or ($InstallAdminTool -eq $true)){
installIIS
installPHP
}
if($InstallShrine -eq $true){
installTomcat
}