-
-
Save collinsauve/eb255d10ece06c032140 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# duplicated to https://gist.github.com/awr/a5136e574556ed50ce94 for public access | |
# START http://boxstarter.org/package/url?https://gist.githubusercontent.com/awr/a5136e574556ed50ce94/raw/dev-boxstarter.ps1 | |
# chocolatey initial setup | |
choco feature enable -n=allowGlobalConfirmation -y | |
choco feature enable -n=autoUninstaller -y | |
# Windows setup | |
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar | |
Disable-InternetExplorerESC | |
Update-ExecutionPolicy | |
Install-WindowsUpdate -AcceptEula | |
Update-ExecutionPolicy Unrestricted | |
# install Git & associated | |
cinst git -y -params '"/GitAndUnixToolsOnPath /NoAutoCrlf"' | |
cinst gitextensions -y | |
cinst poshgit -y | |
cinst P4Merge -y | |
$settingsPath = "C:\Code\settings.txt" | |
$settings = @{} | |
if (!(Test-Path "C:\Code")) { | |
cd / | |
mkdir Code | |
} | |
if (Test-Path $settingsPath) { | |
Get-Content $settingsPath | foreach-object -begin {$settings=@{}} -process { $k = [regex]::split($_,'='); if(($k[0].CompareTo("") -ne 0) -and ($k[0].StartsWith("[") -ne $True)) { $settings.Add($k[0], $k[1]) } } | |
} | |
# Configure git | |
$registryPath = "HKCU:\Software\GitExtensions" | |
if (!(Test-Path $registryPath)) { | |
New-Item -Path $registryPath -Force | Out-Null | |
} | |
New-ItemProperty -Path $registryPath -Name "gitssh" -Value "" -PropertyType String -Force | Out-Null | |
New-ItemProperty -Path $registryPath -Name "gitcommand" -Value "" -PropertyType String -Force | Out-Null | |
$settingsPath = "C:\Code\settings.txt" | |
$settings = @{} | |
if (Test-Path $settingsPath) { | |
Get-Content $settingsPath | foreach-object -begin {$settings=@{}} -process { $k = [regex]::split($_,'='); if(($k[0].CompareTo("") -ne 0) -and ($k[0].StartsWith("[") -ne $True)) { $settings.Add($k[0], $k[1]) } } | |
} | |
Write-Host ">> Configure settings" | |
if (!($settings["email"])) { | |
$settings["email"] = Read-Host "What email do you use with git? " | |
} | |
if (!($settings["username"])) { | |
$settings["username"] = Read-Host "Input your Computer username (ENTER for $env:UserName) " | |
if (!($settings["username"])) { | |
$settings["username"] = $env:UserName | |
} | |
} | |
if (!($settings["name"])) { | |
$settings["name"] = Read-Host "Input your Nudge name (ideally $($settings["username"]), but if that is not unique at Nudge then a unique value for all nudge dev resources -- ENTER for $($settings["username"])) " | |
if (!($settings["name"])) { | |
$settings["name"] = $settings["username"] | |
} | |
} | |
if (!($settings["type"])) { | |
$settings["type"] = Read-Host "What type of install is this? [ui,full] (ENTER for ui) " | |
if (!($settings["type"]) -and $settings["type"] -ne "ui") { | |
$settings["type"] = "ui" | |
} else { | |
if (!($settings["db"])) { | |
$settings["db"] = Read-Host "What type of database is this? [local,azure] (ENTER for local) " | |
if (!($settings["db"])) { | |
$settings["db"] = "local" | |
} | |
} | |
if (!($settings["storagekey"])) { | |
$settings["storagekey"] = Read-Host "What Azure Storage key do you have? " | |
} | |
if (!($settings["servicebuskey"])) { | |
$settings["servicebuskey"] = Read-Host "What Azure ServiceBus key do you have? " | |
} | |
} | |
} | |
if (Test-Path $settingsPath) { | |
Remove-Item $settingsPath | |
} | |
foreach ($i in $settings.keys) { | |
Add-Content -Path $settingsPath -Value "$i=$($settings[$i])" | |
} | |
$profile = "C:\Users\$($settings['username'])" | |
$bashProfile = "/c/Users/$($settings['username'])" | |
git config --global user.name $settings["name"] | |
git config --global user.email $settings["email"] | |
git config --global core.autocrlf False | |
git config --global merge.tool p4merge | |
git config --global diff.guitool p4merge | |
git config --global difftool.p4merge.path "C:/Program Files/Perforce/p4merge.exe" | |
git config --global difftool.p4merge.cmd '\"C:/Program Files/Perforce/p4merge.exe\" \"$REMOTE\" \"$MERGED\"' | |
git config --global mergetool.p4merge.path "C:/Program Files/Perforce/p4merge.exe" | |
git config --global mergetool.p4merge.cmd '\"C:/Program Files/Perforce/p4merge.exe\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"' | |
if (!(Test-Path "$profile\.ssh")) { | |
cd $profile | |
mkdir .ssh | |
} | |
cinst boxstarter -y | |
if (!(Test-Path "C:\Code\Relationships")) { | |
# git ssh setup: | |
if (!(Test-Path "$profile\.ssh\id_rsa")) { | |
ssh-keygen -q -C $settings["email"] -f $bashProfile/.ssh/id_rsa | |
} | |
ssh-agent -s | |
ssh-add $bashProfile/.ssh/id_rsa | |
Get-Content "$profile\.ssh\id_rsa.pub" | clip | |
Start-Process -FilePath "https://github.com/settings/ssh" | |
Write-Host "Copied the full contents of $profile\.ssh\id_rsa (currently in your clipboard):" | |
Read-Host "Go to https://github.com/settings/ssh and add as a new key, then press ENTER" | |
ssh -T git@github.com | |
# clone repo | |
git clone git@github.com:stevewoods/Relationships.git /code/Relationships | |
} | |
cinst lessmsi -y | |
cinst webpicmd -y | |
cinst googlechrome -y | |
Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe" | |
cinst Firefox -y | |
Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Mozilla Firefox\firefox.exe" | |
cinst lastpass -y | |
cinst fiddler4 -y | |
Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Fiddler2\Fiddler.exe" | |
cinst procexp -y | |
cinst ConEmu -y | |
Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles}\ConEmu\ConEmu64.exe" | |
cinst atom -y | |
cinst sublimetext3 -y | |
Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles}\Sublime Text 3\sublime_text.exe" | |
Install-ChocolateyFileAssociation ".txt" "$env:programFiles\Sublime Text 3\sublime_text.exe" | |
Install-ChocolateyFileAssociation ".log" "$env:programFiles\Sublime Text 3\sublime_text.exe" | |
cinst slack -y | |
cinst googledrive -y | |
cinst nodejs.install -y | |
cinst jdk8 -y | |
Write-Host ">> .Net Frameworks" | |
WebPICMD /Install /AcceptEula /Products:"NETFramework35,NetFx3,NETFramework4Update402,NetFx4,NetFx4Extended-ASPNET45" | |
Write-Host ">> Node Setup" | |
$nodePath = Join-Path $env:programfiles 'nodejs' | |
if (!($env:Path -like "*$($nodePath)*")) { | |
$env:Path = "$($env:Path);$nodePath" | |
Invoke-Reboot | |
} | |
npm install -g gulp | |
$repoPath = "c:\code\relationships" | |
$bashRepoPath = "/c/code/relationships" | |
function Import-PfxCertificate($certPath, $pfxPass) { | |
$pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2 | |
$pfx.import($certPath,$pfxPass,"Exportable,PersistKeySet") | |
$store = new-object System.Security.Cryptography.X509Certificates.X509Store("My", "LocalMachine") | |
$store.open("MaxAllowed") | |
$store.add($pfx) | |
$store.close() | |
} | |
Write-Host ">> Import Dev Certificates" | |
Import-PfxCertificate -certPath "$repoPath\config\IIS\app.dev.pfx" -pfxPass "6j1hkFIZsOw0" | |
Import-PfxCertificate -certPath "$repoPath\config\IIS\api.dev.pfx" -pfxPass "aut0mat3TGD" | |
Import-PfxCertificate -certPath "$repoPath\config\IIS\raw.dev.pfx" -pfxPass "0f3j3NKOS7pf" | |
Write-Host ">> IIS Products from WebPI" | |
WebPICMD /Install /AcceptEula /Products:"AppWarmUp,ASPNET,ASPNET45,ASPNET_REGIIS_NET4,DefaultDocument,DirectoryBrowse,HiveODBCDriver_x64_2_5,HiveODBCDriver_x86_2_5,HTTPErrors,HTTPLogging,HTTPRedirection,HttpPlatformHandlerv1_0,IIS7,IISManagementConsole,IISManagementScriptsAndTools,ISAPIExtensions,ISAPIFilters,LoggingTools,NETExtensibility,NetFxExtensibility45,RequestFiltering,RequestMonitor,StaticContent,StaticContentCompression,Tracing,WASConfigurationAPI,WASNetFxEnvironment,WASProcessModel,WebSockets,UrlRewrite2,HttpPlatformHandler v1.0" | |
Write-Host ">> IIS Shared Configuration" | |
[System.Reflection.Assembly]::LoadFrom("$env:SystemRoot\system32\inetsrv\Microsoft.Web.Administration.dll") | Out-Null | |
$serverManager = New-Object Microsoft.Web.Administration.ServerManager | |
$config = $serverManager.GetRedirectionConfiguration() | |
$redirectionSection = $config.GetSection("configurationRedirection") | |
$redirectionSection.Attributes["enabled"].Value = "true" | |
$redirectionSection.Attributes["path"].Value = "$repoPath\config\IIS" | |
$serverManager.CommitChanges() | |
Write-Host ">> IIS cert binding" | |
netsh http add sslcert hostnameport=app.dev.neednudge.com:443 certstorename=MY certhash=c7f528dc1b6d3a4e856dbb847ac9cc29b5c6dab5 appid=`{4dc3e181-e14b-4a21-b022-59fc669b0914`} | |
netsh http add sslcert hostnameport=api.dev.neednudge.com:443 certstorename=MY certhash=fc54b43c31155f0d1286cab8c1d06f796ce18d03 appid=`{4dc3e181-e14b-4a21-b022-59fc669b0914`} | |
netsh http add sslcert hostnameport=raw.dev.neednudge.com:443 certstorename=MY certhash=4d0a666d8871cefa4a04d7f7121e345d6a1fb598 appid=`{4dc3e181-e14b-4a21-b022-59fc669b0914`} | |
Write-Host ">> Visual Studio" | |
cinst visualstudio2015enterprise -y | |
Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe" | |
Install-ChocolateyVsixPackage StopOnFirstBuildError http://visualstudiogallery.msdn.microsoft.com/91aaa139-5d3c-43a7-b39f-369196a84fa5/file/44205/5/StopOnFirstBuildError.vsix | |
Install-ChocolateyVsixPackage VSColorOutput http://visualstudiogallery.msdn.microsoft.com/f4d9c2b5-d6d7-4543-a7a5-2d7ebabc2496/file/63103/7/VSColorOutput.vsix | |
Install-ChocolateyVsixPackage PowerShellTools.14.0 https://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597/file/156893/9/PowerShellTools.14.0.vsix | |
Write-Host ">> Update hosts file" | |
$hostsPath = "$env:SystemRoot\System32\drivers\etc\hosts" | |
$hostsFile = Get-Content $hostsPath | |
$devHosts = "127.0.0.1 app.dev.neednudge.com api.dev.neednudge.com raw.dev.neednudge.com cp.dev.neednudge.com" | |
if (!($hostsFile -like "*$($devHosts)*")) { | |
$devHosts | Out-File -encoding ASCII -append $hostsPath | |
Invoke-Reboot | |
} | |
cinst resharper -y | |
Write-Host ">> Azure SDK for vs2015" | |
WebPICMD /Install /AcceptEula /Products:"VWDOrVs2015AzurePack,VWDOrVs2015AzurePack.2.7" | |
function Create-Database([String] $dbName, [String] $repoPath) { | |
# Open ADO.NET Connection with Windows authentification to local SQLEXPRESS\master. | |
$con = New-Object Data.SqlClient.SqlConnection; | |
$con.ConnectionString = "Data Source=.\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;"; | |
$con.Open(); | |
$sql = Get-Content "$repoPath\config\sql\create-master.sql" | |
$cmd = New-Object Data.SqlClient.SqlCommand $sql, $con; | |
$cmd.ExecuteNonQuery(); | |
# Close & Clear all objects. | |
$cmd.Dispose(); | |
$con.Close(); | |
$con.Dispose(); | |
$con = New-Object Data.SqlClient.SqlConnection; | |
$con.ConnectionString = "Data Source=.\SQLEXPRESS;Initial Catalog=$dbName;Integrated Security=True;"; | |
$con.Open(); | |
$sql = Get-Content "$repoPath\config\sql\create-$dbName.sql" | |
$cmd = New-Object Data.SqlClient.SqlCommand $sql, $con; | |
$cmd.ExecuteNonQuery(); | |
# Close & Clear all objects. | |
$cmd.Dispose(); | |
$con.Close(); | |
$con.Dispose(); | |
} | |
if ($settings["type"] -eq "ui") { | |
Write-Host ">> Build the Application" | |
cd $repoPath | |
sh ./build all | |
sh ./update transform ui-transform | |
sh ./update config ui-config | |
} else { | |
Write-Host ">> .Net additional tools" | |
cinst dotpeek -y | |
# IntelliJ IDEA | |
Write-Host ">> Java IDE" | |
cinst intellijidea-community -y | |
# Redis | |
Write-Host ">> Redis" | |
cinst redis-64 -y | |
cinst redis-desktop-manager -y | |
if (!(Get-Service "redis" -ErrorAction SilentlyContinue)) { | |
$redisServerPath = "" | |
Get-ChildItem -Path "C:\ProgramData" -Recurse -Filter "redis-server.exe" -ErrorAction SilentlyContinue | Select-Object -First 1 | ForEach-Object { $redisServerPath = $_.FullName } | |
Start-Process "$redisServerPath" @("--service-install", "$repoPath\config\redis\redis.windows.conf") -NoNewWindow -Wait | |
Set-Service -Name redis -StartupType Automatic | |
Start-Service -Name redis | |
} | |
# Elastic Search | |
Write-Host ">> Elastic Search" | |
cinst ElasticSearchPackage -source "$repoPath\config\dev-win8" -y | |
if (!(Get-Service "elasticsearch-service-x64" -ErrorAction SilentlyContinue)) { | |
$elasticSearchPath = "" | |
Get-ChildItem -Path "C:\ProgramData" -Recurse -Filter "elasticsearch-service-x64.exe" -ErrorAction SilentlyContinue | Select-Object -Last 1 | ForEach-Object { $elasticSearchPath = $_.Directory.Parent.FullName } | |
Start-Process "cmd.exe" @("/c", "$elasticSearchPath\bin\service.bat install") -NoNewWindow -Wait | |
Start-Process "cmd.exe" @("/c", "$elasticSearchPath\bin\service.bat start") -NoNewWindow -Wait | |
Set-Service -Name elasticsearch-service-x64 -StartupType Automatic | |
Copy-Item "$repoPath\config\ElasticSearch\content-stopwords.txt" "$elasticSearchPath\config" -Force | |
} | |
plugin -i lmenezes/elasticsearch-kopf/latest | |
# Cassandra | |
Write-Host ">> Cassandra" | |
cinst CassandraPackage -source "$repoPath\config\dev-win8" -y | |
# DevCenter | |
Write-Host ">> DevCenter" | |
cinst DevCenterPackage -source "$repoPath\config\dev-win8" -y | |
# Tomcat | |
Write-Host ">> Tomcat" | |
cinst TomcatPackage -source "$repoPath\config\dev-win8" -y | |
[Environment]::SetEnvironmentVariable("TOMCAT_HOME", "$env:ProgramW6432\apache-tomcat-8.0.27", "Machine") | |
[Environment]::SetEnvironmentVariable("TOMCAT_CONFIG", "$repoPath\src\Nudge.ContentProcessing.Web\bin\tomcat", "Machine") | |
[Environment]::SetEnvironmentVariable("TOMCAT_JAVA_ARGS", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Dcom.sun.management.jmxremote.port=3334 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false", "Machine") | |
New-Item $env:ProgramData\Nudge -type directory -force | |
Copy-Item $repoPath\src\Nudge.ContentProcessing.Web\setup\refresh-env-and-start.bat $env:ProgramData\Nudge -force | |
Copy-Item $repoPath\src\Nudge.ContentProcessing.Web\setup\tomcat-startup.bat $env:ProgramData\Nudge -force | |
# ContentProcessing config | |
New-Item $env:ProgramData\Nudge\log -type directory -force | |
[Environment]::SetEnvironmentVariable("LogPath", "$env:ProgramData\Nudge\log", "Machine") | |
New-Item $env:ProgramData\Nudge\debug -type directory -force | |
[Environment]::SetEnvironmentVariable("DebugPath", "$env:ProgramData\Nudge\debug", "Machine") | |
New-Item $env:ProgramData\Nudge\audit -type directory -force | |
[Environment]::SetEnvironmentVariable("AuditingPath", "$env:ProgramData\Nudge\audit", "Machine") | |
New-Item $env:ProgramData\Nudge\cache -type directory -force | |
[Environment]::SetEnvironmentVariable("CachePath", "$env:ProgramData\Nudge\cache", "Machine") | |
[Environment]::SetEnvironmentVariable("Environment_Name", "Dev", "Machine") | |
# Splunk (monitoring) | |
# cinst splunk | |
if ($settings["db"] -eq "local") { | |
cinst Sql2014ExpressPackage -source "$repoPath\config\dev-win8" -y | |
Create-Database "Relationships" "$repoPath" | |
} else { | |
cinst mssqlservermanagementstudio2014express -y | |
} | |
$configPath = "$repoPath\src\Nudge.Core\app.$($settings["name"]).config" | |
if (!(Test-Path "$configPath")) { | |
Write-Host ">> Create app.$($settings["name"]).config file" | |
$configContent = "" | |
if ($settings["db"] -eq "local") { | |
$configContent = Get-Content "$repoPath\config\Dev-Win8\app.template-localdb.config" | |
} else { | |
$configContent = Get-Content "$repoPath\config\Dev-Win8\app.template-azuredb.config" | |
} | |
$configContent = $configContent -replace "NAMEPLACEHOLDER",$settings["name"] | |
$configContent = $configContent -replace "STORAGEKEYPLACEHOLDER",$settings["storagekey"] | |
$configContent = $configContent -replace "SERVICEBUSKEYPLACEHOLDER",$settings["servicebuskey"] | |
$configContent | Out-File -encoding utf8 -Force -FilePath $configPath | |
} | |
Write-Host ">> Build the Application" | |
cd $repoPath | |
sh ./build all | |
sh ./update config $settings["name"] | |
sh ./update all $settings["name"] | |
} | |
iisreset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment