-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.ps1
More file actions
executable file
·165 lines (140 loc) · 4.94 KB
/
bootstrap.ps1
File metadata and controls
executable file
·165 lines (140 loc) · 4.94 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/local/bin/powershell
#Requires -Version 5.0
#
# WINDOWS 10 BOOTSTRAP
#
# This script will be run directly if using Windows 10
# TODO: Run as administrator
#Set-ExecutionPolicy RemoteSigned
#
# Functions
function SetUserEnv ($key, $value)
{
Write-Host "Setting $key as user-level environment variable"
[Environment]::SetEnvironmentVariable($key, $value, 'User')
}
function Download ([string] $url, [string] $dest, [string] $filename = $null)
{
# Follow redirect
Write-Host "Requesting to $url"
$req = Invoke-WebRequest `
-Uri $url `
-MaximumRedirection 0 `
-ErrorAction Ignore `
-UserAgent 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36'
If ($req.StatusDescription -eq 'Moved Temporarily') { $url = $req.Headers.Location }
# Download if not exist
If (!$filename) { $filename = Split-Path $url -Leaf }
$destFile = "$dest\$filename"
If (!(Test-Path -Path $destFile -PathType Leaf)) {
Write-Host "Downloading $filename"
Invoke-WebRequest -Uri $url -OutFile $destFile
}
}
function Run ([string] $path, [string] $argv = $null)
{
$filename = Split-Path $path -Leaf
Write-Output "Running $filename"
If (!$argv)
{
Start-Process -FilePath $path -Wait
Return
}
Start-Process -FilePath $path -ArgumentList $($argv -split '; ') -Wait
#Invoke-Expression -Command "$path [string]$argv"
}
function RunAs ([string] $path, [string] $argv = $null)
{
$filename = Split-Path $path -Leaf
Write-Output "Running $filename"
If (!$argv)
{
Start-Process -FilePath $path -Verb runas -Wait
Return
}
Start-Process -FilePath $path -ArgumentList $($argv -split '; ') -Verb runas -Wait
}
function Mklink ([string] $src, [string] $dst)
{
Write-Host "Creating symbolic link $dst"
Start-Process `
-FilePath 'powershell' `
-ArgumentList $("New-Item -Path $dst -ItemType SymbolicLink -Value $src" -split '; ') `
-Verb runas `
-Wait
}
function Extract ([string] $inpath, [string] $outpath)
{
Write-Host "Extracting to $outpath"
Expand-Archive -Path $inpath -DestinationPath $outpath
}
#
# Set common variables
$cwd = Get-Location
$develPath = "$env:USERPROFILE\Developer"
$downloadPath = "$env:HOMEPATH\Downloads"
#Set-Location -Path $cwd
#
# Create ~/Developer directory for common use cases
If (!(Test-Path -Path $develPath -PathType Container))
{
New-Item -ItemType Directory -Path $develPath
New-Item -ItemType Directory -Path "$develPath\bin"
New-Item -ItemType Directory -Path "$develPath\opt"
}
SetUserEnv 'Path' "$env:Path;$develPath\bin"
#
# Software installation
If (!(Test-Path -Path $downloadPath -PathType Container))
{
New-Item -ItemType Directory -Path $downloadPath
}
# .NET Core SDK for Windows
#Download `
# 'https://go.microsoft.com/fwlink/?LinkID=827524' `
# $downloadPath `
# 'DotNetCore.1.0.1-SDK.1.0.0.Preview2-003133-x64.exe'
#Run "$downloadPath\DotNetCore.1.0.1-SDK.1.0.0.Preview2-003133-x64.exe"
# 7-Zip
#Download 'http://www.7-zip.org/a/7z1604-x64.msi' $downloadPath
#Run "$downloadPath\7z1604-x64.msi" '/promptrestart'
# Git for Windows
Download `
'https://github.com/git-for-windows/git/releases/download/v2.10.1.windows.1/Git-2.10.1-64-bit.exe' `
$downloadPath
Run "$downloadPath\Git-2.10.1-64-bit.exe"
# ConEmu
# FIXME: Impossible to download
#Download 'https://www.fosshub.com/ConEmu.html/ConEmuSetup.161009a.exe' $downloadPath 'ConEmuSetup.161009a.exe'
#Run "$downloadPath\ConEmuSetup.161009a.exe"
$conemuXml = "$env:APPDATA\ConEmu.xml"
If (Test-Path -Path $conemuXml -PathType Leaf) { Remove-Item $conemuXml }
Mklink "$cwd\windows\AppData\Roaming\ConEmu.xml" $conemuXml
# Docker
RunAs 'powershell' 'Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All'
Download 'https://download.docker.com/win/stable/InstallDocker.msi' $downloadPath
Run "$downloadPath\InstallDocker.msi"
# Visual Studio Code
Download 'https://go.microsoft.com/fwlink/?LinkID=623230' $downloadPath 'VSCodeSetup-stable.exe'
Run "$downloadPath\VSCodeSetup-stable.exe"
$vscodeSettingJson = "$env:APPDATA\Code\User\settings.json"
If (Test-Path -Path $vscodeSettingJson -PathType Leaf) { Remove-Item $vscodeSettingJson }
Mklink "$cwd\windows\AppData\Roaming\Code\User\settings.json" $vscodeSettingJson
Run 'code' @"
--install-extension
christian-kohler.path-intellisense
dbaeumer.vscode-eslint
EditorConfig.EditorConfig
ilich8086.classic-asp
ms-vscode.csharp
ms-vscode.PowerShell
shinnn.stylelint
vscodevim.vim
"@
# Selenium
Download `
'http://selenium-release.storage.googleapis.com/3.0/selenium-server-standalone-3.0.0.jar' `
"$develPath\opt"
Mklink "$cwd\windows\Developer\bin\selenium.bat" "$develPath\bin\selenium.bat"
Download 'http://chromedriver.storage.googleapis.com/2.24/chromedriver_win32.zip' $downloadPath
Extract "$downloadPath\chromedriver_win32.zip" "$develPath\bin"