installer.ps1 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. #
  2. # Versions of software (will need to be updated from time to time)
  3. #
  4. $node_installer_file = "node-v0.10.13-x64.msi"
  5. $node_installer_path = "v0.10.13/x64/$node_installer_file"
  6. $python_installer_file = "python-2.7.5.amd64.msi"
  7. $python_installer_path = "2.7.5/$python_installer_file"
  8. $python_version = "27"
  9. $wincache_installer_file = "wincache-1.3.4-5.4-nts-vc9-x86.exe"
  10. $wincache_installer_path = "wincache-1.3.4/$wincache_installer_file"
  11. $go_installer_file = "go1.2.windows-amd64.msi"
  12. $jre_installer_file = "jre-7u51-windows-x64.exe"
  13. $jdk_installer_file = "jdk-7u51-windows-x64.exe"
  14. $jdk_master_hash = "d1367410be659f1b47e554e7bd011ea0"
  15. # http://www.oracle.com/technetwork/java/javase/downloads/java-se-binaries-checksum-1956892.html
  16. $resin_version = "resin-4.0.36"
  17. $resin_installer_file = "$resin_version.zip"
  18. $ant_version = "apache-ant-1.9.2"
  19. $ant_installer_file = "$ant_version-bin.zip"
  20. $maven_version = "apache-maven-3.0.5"
  21. $maven_installer_file = "$maven_version-bin.zip"
  22. $maven_installer_path = "maven-3/3.0.5/binaries/$maven_installer_file"
  23. $scala_version = "2.10.2"
  24. $play_version = "2.2.0"
  25. $play_installer_file = "play-$play_version.zip"
  26. $mercurial_installer_file = "mercurial-2.6.1-x64.msi"
  27. $cygwin_installer_file = "setup-x86_64.exe"
  28. $basedir = "C:\FrameworkBenchmarks"
  29. $workdir = "$basedir\installs"
  30. New-Item -Path $workdir -Type directory -Force | Out-Null
  31. function GetMd5FileHash($fileName) {
  32. [Reflection.Assembly]::LoadWithPartialName("System.Security") | out-null
  33. $md5 = [System.Security.Cryptography.MD5]::Create()
  34. $file = [System.IO.File]::OpenRead($fileName)
  35. $hash = $md5.ComputeHash($file)
  36. $file.Dispose()
  37. $sb = New-Object System.Text.StringBuilder
  38. $hash | % { [Void]$sb.Append($_.ToString("x2")) }
  39. $sb.ToString()
  40. }
  41. #
  42. # Chocolatey package manager
  43. #
  44. Write-Host "Installing Chocolatey package manager"
  45. Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
  46. #
  47. # ASP.NET
  48. #
  49. Write-Host "Installing IIS, .NET and ASP.NET..."
  50. # Enable Windows Update to get rid of the yellow warnings
  51. # But this is not strictly neccessary
  52. $Updates = (New-Object -ComObject "Microsoft.Update.AutoUpdate").Settings
  53. $Updates.NotificationLevel = 2 # Notify before download
  54. $Updates.Save()
  55. $Updates.Refresh()
  56. Install-WindowsFeature Web-Server
  57. Install-WindowsFeature Web-Mgmt-Console
  58. Install-WindowsFeature NET-Framework-45-ASPNET
  59. Install-WindowsFeature Web-Asp-Net45
  60. $env:Path += ";C:\Windows\system32\inetsrv"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  61. # Optimize performance
  62. appcmd set config -section:httpProtocol /allowKeepAlive:true | Out-Null
  63. appcmd set config -section:httpLogging /dontLog:True | Out-Null
  64. # Enable detailed error pages
  65. #appcmd set config -section:system.webServer/httpErrors -errorMode:Detailed | Out-Null
  66. # Increase queue length for DefaultAppPool to avoid HTTP 503 errors coming from HTTP.SYS
  67. appcmd set apppool DefaultAppPool /queueLength:65535
  68. # Increase appConcurrentRequestLimit to avoid HTTP 503.2 errors from IIS http://support.microsoft.com/kb/943891
  69. appcmd set config -section:system.webServer/serverRuntime /appConcurrentRequestLimit:65535
  70. # URL Rewrite
  71. $rewrite_url = "http://download.microsoft.com/download/6/7/D/67D80164-7DD0-48AF-86E3-DE7A182D6815/rewrite_2.0_rtw_x64.msi"
  72. $rewrite_local = "$workdir\rewrite_2.0_rtw_x64.msi"
  73. (New-Object System.Net.WebClient).DownloadFile($rewrite_url, $rewrite_local)
  74. Start-Process "msiexec" "/i $rewrite_local /passive" -Wait
  75. #
  76. # Tools for building .NET projects on the server
  77. #
  78. Write-Host "`nInstalling .NET build tools...`n"
  79. # .NET Framework 4.5 SDK
  80. $sdktools_url = "http://download.microsoft.com/download/F/1/3/F1300C9C-A120-4341-90DF-8A52509B23AC/standalonesdk/sdksetup.exe"
  81. $sdktools_local = "$workdir\sdksetup.exe"
  82. (New-Object System.Net.WebClient).DownloadFile($sdktools_url, $sdktools_local)
  83. Start-Process "$workdir\sdksetup.exe" "/features OptionId.NetFxSoftwareDevelopmentKit /q /layout $workdir\sdksetup" -Wait
  84. Start-Process "msiexec" "/i $workdir\sdksetup\Redistributable\4.5.50710\sdk_tools4.msi VSEXTUI=1" -Wait
  85. # Web Deploy 3.0
  86. $webdeploy_url = "http://download.microsoft.com/download/1/B/3/1B3F8377-CFE1-4B40-8402-AE1FC6A0A8C3/WebDeploy_amd64_en-US.msi"
  87. $webdeploy_local = "$workdir\WebDeploy_amd64_en-US.msi"
  88. (New-Object System.Net.WebClient).DownloadFile($webdeploy_url, $webdeploy_local)
  89. Start-Process "msiexec" "/i $webdeploy_local /passive" -Wait
  90. #
  91. # node.js
  92. #
  93. Write-Host "Installing node.js...`n"
  94. $node_installer_url = "http://nodejs.org/dist/$node_installer_path"
  95. $node_installer_local = "$workdir\$node_installer_file"
  96. (New-Object System.Net.WebClient).DownloadFile($node_installer_url, $node_installer_local)
  97. Start-Process $node_installer_local '/passive' -Wait
  98. $env:Path += ";C:\Program Files\nodejs"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  99. #
  100. # Python
  101. #
  102. Write-Host "Installing Python...`n"
  103. $python_installer_url = "http://www.python.org/ftp/python/$python_installer_path"
  104. $python_installer_local = "$workdir\$python_installer_file"
  105. (New-Object System.Net.WebClient).DownloadFile($python_installer_url, $python_installer_local)
  106. Start-Process $python_installer_local '/passive' -Wait
  107. $env:Path += ";C:\Python$python_version"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  108. #
  109. # PHP
  110. #
  111. Write-Host "Installing PHP..."
  112. # Locate current PHP 5.4 release
  113. Write-Host "Looking for current PHP 5.4 release"
  114. $php_download_page_url = 'http://windows.php.net/download/'
  115. $php_download_page_file = [IO.Path]::GetTempFileName()
  116. Write-Host "Downloading from $php_download_page_url into $php_download_page_file"
  117. Try {
  118. (New-Object System.Net.WebClient).DownloadFile($php_download_page_url, $php_download_page_file)
  119. } Catch {
  120. Write-Host "ERROR: Could not download from $php_download_page_url."
  121. Write-Host $_.Exception.Message
  122. Exit 1
  123. }
  124. $file = (cat $php_download_page_file) -join ""
  125. if ($file -match '(?s)h4 id="php-5.4-nts-VC9-x86".*?href="/downloads/releases/(.*?)">Zip</a>') {
  126. $php_installer_file = $matches[1]
  127. $php_installer_url = "http://windows.php.net/downloads/releases/$php_installer_file"
  128. Write-Host "Current PHP 5.4 release found at $php_installer_url"
  129. }
  130. else {
  131. Write-Host "ERROR: Current PHP release was not found. Aborting."
  132. Exit 1
  133. }
  134. # Download PHP
  135. $php_installer_local = "$workdir\$php_installer_file"
  136. Try {
  137. (New-Object System.Net.WebClient).DownloadFile($php_installer_url, $php_installer_local)
  138. } Catch {
  139. Write-Host "ERROR: Could not download from $php_installer_url. "
  140. Write-Host $_.Exception.Message
  141. Exit 1
  142. }
  143. # Install PHP
  144. $php = "C:\PHP"
  145. [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
  146. [System.IO.Compression.ZipFile]::ExtractToDirectory($php_installer_local, $php) | Out-Null
  147. $env:Path += ";" + $php; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  148. # php.ini
  149. $phpini = "$php\php.ini"
  150. Copy-Item "$php\php.ini-production" $phpini
  151. (Get-Content $phpini) -Replace ";date.timezone =", "date.timezone = UTC" | Set-Content $phpini
  152. (Get-Content $phpini) -Replace "short_open_tag = Off", "short_open_tag = On" | Set-Content $phpini
  153. (Get-Content $phpini) -Replace "display_errors = Off", "display_errors = Off" | Set-Content $phpini
  154. (Get-Content $phpini) -Replace "log_errors = On", "log_errors = Off" | Set-Content $phpini
  155. (Get-Content $phpini) -Replace "output_buffering = 4096", "output_buffering = Off" | Set-Content $phpini
  156. (Get-Content $phpini) -Replace ";cgi.force_redirect = 1", "cgi.force_redirect = 0" | Set-Content $phpini
  157. (Get-Content $phpini) -Replace ";fastcgi.impersonate = 1", "fastcgi.impersonate = 0" | Set-Content $phpini
  158. (Get-Content $phpini) -Replace ";fastcgi.logging = 0", "fastcgi.logging = 0" | Set-Content $phpini
  159. (Get-Content $phpini) -Replace '; extension_dir = "./"', "extension_dir = `"$php\ext`"" | Set-Content $phpini
  160. (Get-Content $phpini) -Replace ";extension=", "extension=" | Set-Content $phpini
  161. (Get-Content $phpini) -Replace "extension=php_(interbase|oci8|oci8_11g|firebird|oci|pspell|sybase_ct|zip|pdo_firebird|pdo_oci|snmp).dll.*", "" | Set-Content $phpini
  162. # IIS with PHP via FastCGI
  163. Install-WindowsFeature Web-CGI | Out-Null
  164. appcmd set config -section:system.webServer/fastCgi /+"[fullPath='C:\PHP\php-cgi.exe', arguments='', maxInstances='0', instanceMaxRequests='10000', queueLength='1000', rapidFailsPerMinute='10', idleTimeout='300', activityTimeout='30', requestTimeout='90', protocol='NamedPipe', flushNamedPipe='False']" /commit:apphost | Out-Null
  165. appcmd set config -section:system.webServer/fastCgi /+"[fullPath='C:\PHP\php-cgi.exe'].environmentVariables.[name='PHPRC', value='C:\PHP\php.ini']" /commit:apphost | Out-Null
  166. appcmd set config -section:system.webServer/handlers /+"[name='PHP FastCGI', path='*.php', modules='FastCgiModule', verb='*', scriptProcessor='C:\PHP\php-cgi.exe', resourceType='File', requireAccess='Script']" /commit:apphost | Out-Null
  167. # phpinfo() test file
  168. Set-Content "c:\inetpub\wwwroot\phpinfo.php" "<?php phpinfo(); ?>"
  169. # wincache
  170. $wincache_url = "http://heanet.dl.sourceforge.net/project/wincache/$wincache_installer_path"
  171. $wincache_local = "$workdir\$wincache_installer_file"
  172. (New-Object System.Net.WebClient).DownloadFile($wincache_url, $wincache_local)
  173. Start-Process $wincache_local "/q /T:$php\ext" -Wait
  174. Move-Item "$php\ext\wincache*" "c:\inetpub\wwwroot"
  175. Set-ItemProperty "c:\inetpub\wwwroot\wincache.php" -name IsReadOnly -value $false
  176. (Get-Content "c:\inetpub\wwwroot\wincache.php") -Replace "'USE_AUTHENTICATION', 1", "'USE_AUTHENTICATION', 0" | Set-Content "c:\inetpub\wwwroot\wincache.php"
  177. Add-Content $phpini "`n`n[PHP]`n"
  178. Add-Content $phpini "extension=php_wincache.dll"
  179. # composer
  180. $composer_url = "https://getcomposer.org/Composer-Setup.exe"
  181. $composer_local = "$workdir\Composer-Setup.exe"
  182. (New-Object System.Net.WebClient).DownloadFile($composer_url, $composer_local)
  183. Start-Process $composer_local "/silent" -Wait
  184. $env:Path += ";C:\ProgramData\Composer\bin"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  185. Write-Host ""
  186. #
  187. # Go
  188. #
  189. Write-Host "Installing Go...`n"
  190. $go_url = "http://go.googlecode.com/files/$go_installer_file"
  191. $go_local = "$workdir\$go_installer_file"
  192. (New-Object System.Net.WebClient).DownloadFile($go_url, $go_local)
  193. Start-Process $go_local "/passive" -Wait
  194. $env:Path += ";C:\Go\bin"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  195. #
  196. # Java
  197. #
  198. Write-Host "Installing Java...`n"
  199. # jre
  200. #Write-Host "Installing JRE...`n"
  201. #$jre_url = "http://img.cs.montana.edu/windows/$jre_installer_file"
  202. #$jre_local = "$workdir\$jre_installer_file"
  203. #$jre_dir = "C:\Java\jre"
  204. #(New-Object System.Net.WebClient).DownloadFile($jre_url, $jre_local)
  205. #Start-Process $jre_local "/s INSTALLDIR=$jre_dir" -Wait
  206. #$env:Path += ";$jre_dir\bin"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  207. #$env:JAVA_HOME = $jre_dir; [Environment]::SetEnvironmentVariable("JAVA_HOME", $jre_dir, [System.EnvironmentVariableTarget]::Machine)
  208. # jdk
  209. Write-Host "Installing JDK...`n"
  210. $jdk_url = "http://ghaffarian.net/downloads/Java/JDK/$jdk_installer_file"
  211. $jdk_local = "$workdir\$jdk_installer_file"
  212. $jdk_dir = "C:\Java\jdk"
  213. (New-Object System.Net.WebClient).DownloadFile($jdk_url, $jdk_local)
  214. $jdk_local_hash = GetMd5FileHash($jdk_local)
  215. if ($jdk_master_hash -ne $jdk_local_hash)
  216. {
  217. Write-Host $jdk_master_hash
  218. Write-Host $jdk_local_hash
  219. Write-Host "JDK file checksum mismatch. Aborting!"
  220. Exit 1
  221. }
  222. Start-Process $jdk_local "/s INSTALLDIR=$jdk_dir" -Wait
  223. $env:Path += ";$jdk_dir\bin"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  224. $env:JAVA_HOME = $jdk_dir; [Environment]::SetEnvironmentVariable("JAVA_HOME", $jdk_dir, [System.EnvironmentVariableTarget]::Machine)
  225. # resin
  226. Write-Host "Installing Resin...`n"
  227. $resin_url = "http://www.caucho.com/download/$resin_installer_file"
  228. $resin_local = "$workdir\$resin_installer_file"
  229. $resin_dir = "C:\Java\resin"
  230. (New-Object System.Net.WebClient).DownloadFile($resin_url, $resin_local)
  231. [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
  232. [System.IO.Compression.ZipFile]::ExtractToDirectory($resin_local, $workdir) | Out-Null
  233. Move-Item "$workdir\$resin_version" $resin_dir
  234. Copy-Item "$basedir\config\resin.properties" "$resin_dir\conf\resin.properties"
  235. [Environment]::SetEnvironmentVariable("RESIN_HOME", $resin_dir, [System.EnvironmentVariableTarget]::Machine)
  236. #$env:Path += ";$resin_dir\bin"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  237. # ant
  238. #Write-Host "Installing Ant...`n"
  239. #$ant_url = "http://apache.mirrors.hoobly.com//ant/binaries/$ant_installer_file"
  240. #$ant_local = "$workdir\$ant_installer_file"
  241. #$ant_dir = "C:\Java\ant"
  242. #(New-Object System.Net.WebClient).DownloadFile($ant_url, $ant_local)
  243. #[System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
  244. #[System.IO.Compression.ZipFile]::ExtractToDirectory($ant_local, $workdir) | Out-Null
  245. #Move-Item "$workdir\$ant_version" $ant_dir
  246. #$env:Path += ";$ant_dir\bin"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  247. # maven
  248. Write-Host "Installing Maven...`n"
  249. $maven_url = "http://mirror.cc.columbia.edu/pub/software/apache/maven/$maven_installer_path"
  250. $maven_local = "$workdir\$maven_installer_file"
  251. $maven_dir = "C:\Java\maven"
  252. (New-Object System.Net.WebClient).DownloadFile($maven_url, $maven_local)
  253. [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
  254. [System.IO.Compression.ZipFile]::ExtractToDirectory($maven_local, $workdir) | Out-Null
  255. Move-Item "$workdir\$maven_version" $maven_dir
  256. $env:Path += ";$maven_dir\bin"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  257. # scala
  258. cinst scala -version $scala_version
  259. # play
  260. $play_url = "http://downloads.typesafe.com/play/$play_version/$play_installer_file"
  261. $play_local = "$workdir\$play_installer_file"
  262. $play_dir = "C:\Java\play"
  263. (New-Object System.Net.WebClient).DownloadFile($play_url, $play_local)
  264. [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
  265. [System.IO.Compression.ZipFile]::ExtractToDirectory($play_local, $workdir) | Out-Null
  266. Move-Item "$workdir\play-$play_version" $play_dir
  267. $env:Path += ";$play_dir"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  268. #
  269. # Firewall
  270. #
  271. Write-Host "Configuring firewall...`n"
  272. New-NetFirewallRule -DisplayName "HTTP 8080" -Action Allow -Direction Inbound -LocalPort 8080 -Protocol TCP | Out-Null
  273. #
  274. # Mercurial
  275. #
  276. Write-Host "Installing Mercurial...`n"
  277. $hg_installer_url = "https://bitbucket.org/tortoisehg/files/downloads/$mercurial_installer_file"
  278. $hg_installer_local = "$workdir\$mercurial_installer_file"
  279. (New-Object System.Net.WebClient).DownloadFile($hg_installer_url, $hg_installer_local)
  280. Start-Process $hg_installer_local '/passive' -Wait
  281. $env:Path += ";C:\Program Files\Mercurial"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  282. #
  283. # Cygwin (including sftp)
  284. #
  285. Write-Host "Installing Cygwin...`n"
  286. $cygwin_installer_url = "http://cygwin.com/$cygwin_installer_file"
  287. $cygwin_installer_dir = $workdir + "\cygwin-installer"
  288. New-Item -Path $cygwin_installer_dir -Type directory -Force | Out-Null
  289. $cygwin_installer_local = "$cygwin_installer_dir\$cygwin_installer_file"
  290. (New-Object System.Net.WebClient).DownloadFile($cygwin_installer_url, $cygwin_installer_local)
  291. $cygwin_install_dir = "C:\Cygwin"
  292. Start-Process $cygwin_installer_local "-q -n -l $cygwin_installer_dir -s http://mirrors.kernel.org/sourceware/cygwin/ -R $cygwin_install_dir -P openssh" -WorkingDirectory "$cygwin_installer_dir" -Wait -RedirectStandardOutput $cygwin_installer_dir\install.log
  293. $env:Path += ";$cygwin_install_dir;$cygwin_install_dir\bin"; [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
  294. cd $basedir