-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_platform.ps1
299 lines (261 loc) · 12.5 KB
/
install_platform.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
##### SET SOME GLOBAL VARIABLES #####
$rootDrive = "C:"
$svnworkHome = $rootDrive + "\svnwork"
$toolsHome = $rootDrive + "\tools"
$javaHome = $toolsHome + "\java\jdk"
$mavenHome = $toolsHome + "\maven"
$userHome = $env:USERPROFILE
$time = Get-Date -Format r
##### IMPORT SVN URLS #####
. "ignoredFiles\svnUrls.ps1"
##### CREATE LOG FILE #####
$logfile = $svnworkHome + "\logfile.txt"
function logEvent ($logString) {
$time = Get-Date -Format T
Write-Output "$logString $time"
Write-Output "$logString $time" >> $logfile
}
##### FUNCTIONS FOR SVNWORK INSTALL #####
##### TOOLS SETUP #####
##### CREATE DIRECTORIES #####
function setupDirectories {
$dirList = 'prr','defaultui','customers','techservices','svnscripts'
foreach ($dir in $dirList)
{
if ((Test-Path $svnworkHome\$dir) -eq $True) {
logEvent "$dir already exists"
}
else
{
New-Item -Type directory -Path $svnworkHome\$dir
logEvent "Created $svnworkHome\$dir"
}
}
}
function getFiles ($remoteUrl, $localFolder, $currentBranchVersion, $workingClean)
{
logEvent ("Installing {0}" -f $localFolder)
if ($currentBranchVersion)
{
svn co ($remoteUrl+$branchVersion) $svnworkHome\$localFolder\$branchVersion\$workingClean
}
else
{
svn co $remoteUrl $svnworkHome\$localFolder\trunk\$workingClean
}
if ($workingClean -eq 'clean')
{
if ($currentBranchVersion)
{
logEvent "Installing $localFolder\$branchVersion clean to working"
copy-item $svnworkHome\$localFolder\$branchVersion\clean -destination $svnworkHome\$localFolder\$branchVersion\working -recurse
}
else
{
logEvent "Copying $localFolder clean to working"
copy-item $svnworkHome\$localFolder\trunk\clean -destination $svnworkHome\$localFolder\trunk\working -recurse
}
}
}
function setUpBazaarvoiceHome {
logEvent "Creating directory structure for \home\bazaarvoice... "
New-Item -Type directory -Path $rootDrive\home\bazaarvoice
$dirList = 'config-branch','config-trunk','customers-trunk','promote-logs','reports','logs\diagnostic','logs\request'
foreach ($dir in $dirList)
{
if ((Test-Path $rootDrive\home\bazaarvoice\$dir) -eq $True) {
logEvent "$dir already exists"
}
else
{
New-Item -Type directory -Path $rootDrive\home\bazaarvoice\$dir
logEvent "Created $rootDrive\home\bazaarvoice\$dir"
}
}
logEvent "Setting up config-branch... "
cd $rootDrive\home\bazaarvoice\config-branch
New-Item -Type directory -Path 10-localhost
Copy-Item $svnworkHome\prr\branch\working\metadata\home\config\30-common\log4j.xml $rootDrive\home\bazaarvoice\config-branch\10-localhost
createSymLink 15-overrides-dev-dbscripts $svnworkHome\prr\branch\working\metadata\home\config\15-overrides-dev-dbscripts
createSymLink 20-overrides-dev $svnworkHome\prr\branch\working\metadata\home\config\20-overrides-dev
createSymLink 25-overrides-dev-lab-austin $svnworkHome\prr\branch\working\metadata\home\config\25-overrides-dev-lab-austin
createSymLink 30-common $svnworkHome\prr\branch\working\metadata\home\config\30-common
logEvent "Setting up config-trunk... "
cd $rootDrive\home\bazaarvoice\config-trunk
New-Item -Type directory -Path 10-localhost
Copy-Item $svnworkHome\prr\trunk\working\metadata\home\config\30-common\log4j.xml $rootDrive\home\bazaarvoice\config-trunk\10-localhost
createSymLink 15-overrides-dev-dbscripts $svnworkHome\prr\trunk\working\metadata\home\config\15-overrides-dev-dbscripts
createSymLink 20-overrides-dev $svnworkHome\prr\trunk\working\metadata\home\config\20-overrides-dev
createSymLink 25-overrides-dev-lab-austin $svnworkHome\prr\trunk\working\metadata\home\config\25-overrides-dev-lab-austin
createSymLink 30-common $svnworkHome\prr\trunk\working\metadata\home\config\30-common
logEvent "Setting up symbolic links in \home\bazaarvoice for branch use... "
cd $rootDrive\home\bazaarvoice
createSymLink customers $svnworkHome\customers\trunk\working
createSymLink config config-branch
createSymLink defaultui $svnworkHome\defaultui\branch\working
logEvent "Copying env.xml, host_overrides.properties, portal_endpoints.properties, and jetty.properties for config-branch... "
copy-item $svnworkHome\techservices\trunk\working\tools\misc\dev-install\env.xml $rootDrive\home\bazaarvoice\config-branch\10-localhost
copy-item $svnworkHome\techservices\trunk\working\tools\misc\dev-install\host_overrides.properties $rootDrive\home\bazaarvoice\config-branch\10-localhost
copy-item $svnworkHome\techservices\trunk\working\tools\misc\dev-install\portal_endpoints.properties $rootDrive\home\bazaarvoice\config-branch\10-localhost
copy-item $svnworkHome\techservices\trunk\working\tools\misc\dev-install\jetty.properties $rootDrive\home\bazaarvoice\config-branch\10-localhost
logEvent "Copying env.xml host_overrides.properties, portal_endpoints.properties, and jetty.properties for config-trunk... "
copy-item $svnworkHome\techservices\trunk\working\tools\misc\dev-install\env.xml $rootDrive\home\bazaarvoice\config-trunk\10-localhost
copy-item $svnworkHome\techservices\trunk\working\tools\misc\dev-install\host_overrides.properties $rootDrive\home\bazaarvoice\config-trunk\10-localhost
copy-item $svnworkHome\techservices\trunk\working\tools\misc\dev-install\portal_endpoints.properties $rootDrive\home\bazaarvoice\config-trunk\10-localhost
copy-item $svnworkHome\techservices\trunk\working\tools\misc\dev-install\jetty.properties $rootDrive\home\bazaarvoice\config-trunk\10-localhost
logEvent "Writing production_secret_key.bin for config-branch... "
Write-Output "3c774ac04349bbbf861cd59cb7594d09892139227b3dda3411e3f0cdf96da54a" > $rootDrive\home\bazaarvoice\config-branch\production_secret_key.bin
logEvent "Writing production_secret_key.bin for config-trunk... "
Write-Output "3c774ac04349bbbf861cd59cb7594d09892139227b3dda3411e3f0cdf96da54a" > $rootDrive\home\bazaarvoice\config-trunk\production_secret_key.bin
}
function createSymLink ($linkName, $linkUrl) {
Junction.exe $linkName $linkUrl
}
function getToolInstallers {
logEvent "Copying installers to local path"
New-Item -Type directory -Path c:\temp\installers
cd "\\ausfs01\Client Services\Implementation Design\_Personal Folders\JoshM\"
Copy-Item *.* "c:\temp\installers"
}
function deleteToolInstallers {
Remove-Item c:\temp\installers -Recurse
logEvent "Deleted installers"
}
function installSubversion {
logEvent ("Installing subversion")
C:\temp\installers\Slik-Subversion-1.6.12-x64.msi /passive
logEvent ("Wait 3 minutes")
Start-Sleep -s 180
logEvent ("Completed installing subversion")
}
function configureSubversion {
"Enable storing of plaintext SVN password" >> $logfile
New-Item -Type directory -Path $userHome\.subversion
"store-plaintext-passwords = yes" > $userHome\.subversion\servers
"Configuring subversion" >> $logfile
svn cat https://dev.bazaarvoice.com/svn/bvc/ops/trunk/scm/client/config > $userHome\.subversion\config
}
function installJava {
logEvent ("Installing java")
C:\temp\installers\jdk-6u30-windows-x64.exe /s INSTALLDIR=$javaHome
logEvent ("Wait 3 minutes")
Start-Sleep -s 180
logEvent ("Completed installing java")
}
function installJunction {
logEvent ("Installing junction")
New-Item -Type directory -Path $toolsHome\junction
cd $toolsHome\junction
$filename = "junction-current.zip"
$shell_app=new-object -com shell.application
$zip_file = $shell_app.namespace("$rootDrive\temp\installers\$filename")
$destination = $shell_app.namespace((Get-Location).Path)
$destination.Copyhere($zip_file.items())
logEvent ("Completed installing junction")
}
function installMaven {
logEvent ("Installing maven")
cd $toolsHome
$filename = "maven-current.zip"
$shell_app=new-object -com shell.application
$zip_file = $shell_app.namespace("$rootDrive\temp\installers\$filename")
$destination = $shell_app.namespace((Get-Location).Path)
$destination.Copyhere($zip_file.items())
Get-ChildItem -Filter "*maven*" | Rename-Item -NewName "maven"
}
function installAnt {
logEvent ("Installing ant")
cd $toolsHome
$filename = "ant-current.zip"
#copy-item \Users\joshua.melvin\Downloads\$filename (Get-Location).Path
$shell_app=new-object -com shell.application
$zip_file = $shell_app.namespace("$rootDrive\temp\installers\$filename")
$destination = $shell_app.namespace((Get-Location).Path)
$destination.Copyhere($zip_file.items())
Get-ChildItem -Filter "*ant*" | Rename-Item -NewName "ant"
logEvent ("Completed installing ant")
}
function installXmlBeans {
logEvent ("Installing xmlbeans")
cd $toolsHome
$filename = "xmlbeans-current.zip"
$shell_app=new-object -com shell.application
$zip_file = $shell_app.namespace("$rootDrive\temp\installers\$filename")
$destination = $shell_app.namespace((Get-Location).Path)
$destination.Copyhere($zip_file.items())
Get-ChildItem -Filter "*xmlbeans*" | Rename-Item -NewName "xmlbeans"
logEvent ("Completed installing xmlbeans")
}
function addEnvSetup {
Add-Content -Path $profile -Value ("`n`$env:JAVA_HOME" + " = `'$javaHome`'")
Add-Content -Path $profile -Value ("`$env:MAVEN_HOME" + " = `'$mavenHome`'")
Add-Content -Path $profile -Value ("`$env:TOOLS_HOME" + " = `'$toolsHome`'")
Add-Content -Path $profile -Value ("`$env:path" + " += `';$toolsHome\junction;$toolsHome\maven\bin;$toolsHome\ant\bin;$toolsHome\xmlbeans;$javaHome;$javaHome\bin;`'")
. $PROFILE
logEvent "Added environment variables to profile"
}
function installTools {
getToolInstallers
installSubversion
configureSubversion
installJava
installJunction
installMaven
installAnt
installXmlBeans
deleteToolInstallers
addEnvSetup
##### RUN JUNCTION FIRST TIME #####
Junction.exe temp c:\temp
$runJunctionOnce = new-object -comobject wscript.shell
$b = $runJunctionOnce.popup("You must accept terms of Junction's first run to continue installing ",0,"Accept Junction terms to continue",1)
Junction.exe -d temp
}
##### BEGIN INSTALLATION #####
try {
New-Item -Type directory -Path $svnworkHome
Write-Output "Windows Bazaarvoice Dev Environment Setup Script" > $logfile
logEvent "Started install at"
installTools
##### GET LATEST BRANCH VERSION #####
$branchVersion = svn ls $branchUrl | Sort-Object -Descending | Select-Object -First 1 -Skip 1 | %{$_ -replace '/','' }
#getSvnScripts
getFiles -remoteUrl $svnScriptsUrl -localFolder svnscripts -workingClean working
#getTechServices
getFiles -remoteUrl $techservicesUrl -localFolder techservices -workingClean working
#getPrrTrunk
getFiles -remoteUrl $prrTrunkUrl -localFolder prr -workingClean working
#getDefaultUiTrunk
getFiles -remoteUrl $defaultUiTrunkUrl -localFolder defaultui -workingClean clean
#getCustomersTrunk
getFiles -remoteUrl $customersTrunkUrl -localFolder customers -workingClean clean
#getPrrBranch $branchVersion
getFiles -remoteUrl $prrBranchUrl -localFolder prr -currentBranchVersion $branchVersion -workingClean working
createSymLink -linkName branch -linkUrl $svnworkHome\prr\$branchVersion
#getDefaultUiBranch $branchVersion
getFiles -remoteUrl $defaultUiBranchUrl -localFolder defaultui -currentBranchVersion $branchVersion -workingClean clean
createSymLink -linkName branch -linkUrl $svnworkHome\defaultui\$branchVersion
setUpBazaarvoiceHome
# INSTALL LOCAL LDAP CERTIFICATE
logEvent "Installing local LDAP certificate... "
keytool.exe -import -alias "shareddev" -storepass "changeit" -keystore $env:JAVA_HOME\jre\lib\security\cacerts -file $svnworkHome\techservices\trunk\working\tools\misc\dev-install\labCA.pem
logEvent " Installing local Maven certificate... "
keytool.exe -import -alias bvrepo -storepass "changeit" -keystore $env:JAVA_HOME\jre\lib\security\cacerts -file $svnworkHome\techservices\trunk\working\tools\misc\dev-install\repo-ssl.cer
##### CONFIGURE MAVEN #####
New-Item -Type directory -Path ($userHome+"\.m2")
Copy-Item ($svnworkHome+"\techservices\trunk\working\tools\bin\maven-install\ts-maven-settings.xml") ($userHome+"\.m2\settings.xml")
New-Item -Type file -Path ($userHome+"\.mavenrc")
echo MAVEN_OPTS='"-Xms256m -Xmx2g -XX:MaxPermSize=256m -server"' > ($userHome+"\.mavenrc")
logEvent ("Completed installing maven")
}
catch
{
logEvent "ERROR: $_"
logEvent "Install failed. Please review errors."
}
finally
{
Write-Output "Install has ended"
}
logEvent "Install completed"
##### END INSTALLATION #####