This repository was archived by the owner on Nov 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathbootstrap.ps1
More file actions
258 lines (223 loc) · 8.57 KB
/
Copy pathbootstrap.ps1
File metadata and controls
258 lines (223 loc) · 8.57 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
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
function Add-EnvPath {
# Get parameters
param(
[Parameter(Mandatory=$true)]
[string] $Path,
[ValidateSet('Machine', 'User', 'Session')]
[string] $Container = 'Session'
)
# Do it for global Path (like SETX but no restriction over 1024 characters)
if(!($env:Path -like "*$Path*")) {
"[INFO] Adding $Path to system path!"
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v Path /t REG_SZ /d "$env:Path;$Path;"
} else {
"[INFO] $Path is already in system path."
}
# Do it for current $env:Path
if ($Container -ne 'Session') {
$containerMapping = @{
Machine = [EnvironmentVariableTarget]::Machine
User = [EnvironmentVariableTarget]::User
}
$containerType = $containerMapping[$Container]
$persistedPaths = [Environment]::GetEnvironmentVariable('Path', $containerType) -split ';'
if ($persistedPaths -notcontains $Path) {
$persistedPaths = $persistedPaths + $Path | where { $_ }
[Environment]::SetEnvironmentVariable('Path', $persistedPaths -join ';', $containerType)
}
}
$envPaths = $env:Path -split ';'
if ($envPaths -notcontains $Path) {
$envPaths = $envPaths + $Path | where { $_ }
$env:Path = $envPaths -join ';'
}
}
# back up the current environment variables
"$env:Path" | Out-File "Path-Backup-$(Get-Date -format yyyyMMddHHmmss).txt"
########################
# #
# Install Chocolatey #
# #
########################
# installation of Chocolatey package management
"[INFO] Installing Chocolatey"
If ($PSVersionTable.PSVersion.Major -Match "2") {
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
} Else {
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
}
choco feature enable -n=allowGlobalConfirmation
########################
# #
# Hasal Installation #
# #
########################
# installation of tools
$tmp = & CMD /C curl --help >$null 2>&1
If ($lastexitcode -notmatch 0) {
"[INFO] Installing Curl"
choco install curl
If ($lastexitcode -notmatch 0) {
"[ERROR] There were problems when installing curl."
Exit
}
} Else {
"[INFO] Curl found in current system. Not going to install it."
}
$tmp = & CMD /C git --help >$null 2>&1
If ($lastexitcode -notmatch 0) {
"[INFO] Installing git"
choco install git.install
If ($lastexitcode -notmatch 0) {
"[ERROR] There were problems when installing git."
Exit
}
Add-EnvPath "C:\Program Files\Git\bin"
} Else {
"[INFO] Git found in current system. Not going to install it."
}
# Install OBS Studio
If (Test-Path "C:\Program Files (x86)\obs-studio\bin\32bit\obs32.exe") {
"[INFO] OBS had been installed."
} Else {
"[INFO] Downloading OBS ..."
pushd thirdParty
If (Test-Path "OBS-Studio-18.0.1-Full.zip") {
Remove-Item "OBS-Studio-18.0.1-Full.zip"
}
CMD /C curl -kLO https://github.com/jp9000/obs-studio/releases/download/18.0.1/OBS-Studio-18.0.1-Full.zip
"[INFO] Installing OBS ..."
Expand-Archive -LiteralPath OBS-Studio-18.0.1-Full.zip -DestinationPath "C:\Program Files (x86)\obs-studio"
popd
$FIRST_OBS = $TRUE
"[INFO] OBS is installed."
}
# installation of Hasal prerequisite
$tmp = & CMD /C java -version >$null 2>&1
If ($lastexitcode -notmatch 0) {
"[INFO] Installing Java 8 -version 8.0.144"
choco install jre8
If ($lastexitcode -notmatch 0) {
"[ERROR] There were problems when installing jre8."
Exit
}
$jre8 = cver jre8 -localonly | findstr jre8
$version = $jre8.Split(' ')[1] -replace "(.*)\.(.*)", "`$1_`$2"
Add-EnvPath "C:\Program Files\Java\jre1.$version\bin"
} Else {
"[INFO] Java found in current system. Not going to install it."
}
$tmp = & CMD /C ffmpeg -help >$null 2>&1
If ($lastexitcode -notmatch 0) {
"[INFO] Installing FFMPEG"
choco install ffmpeg -version 3.2.2.20161219
If ($lastexitcode -notmatch 0) {
"[ERROR] There were problems when installing ffmpeg."
Exit
}
Add-EnvPath "C:\ProgramData\chocolatey\lib\ffmpeg\tools\ffmpeg-3.2.2-win32-static\bin\"
} Else {
"[INFO] FFMPEG found in current system. Not going to install it."
}
$tmp = & CMD /C conda -help >$null 2>&1
If ($lastexitcode -notmatch 0) {
"[INFO] Installing MiniConda"
choco install miniconda
If ($lastexitcode -notmatch 0) {
"[ERROR] There were problems when installing miniconda."
Exit
}
} Else {
"[INFO] MiniConda found in current system. Not going to install it."
}
If (Test-Path C:\Miniconda2\) {
$CondaPath="C:\Miniconda2"
} ElseIf (Test-Path "C:\Program Files\Miniconda2\") {
$CondaPath="C:\Program Files\Miniconda2"
} Else {
$CondaPath="C:\ProgramData\Miniconda2"
}
Add-EnvPath "$CondaPath\Scripts\"
Add-EnvPath "$CondaPath\"
"[INFO] Downloading VCForPython27.msi"
CMD /C curl -kLO https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi
"[INFO] Installing VCForPython27.msi"
msiexec /i VCForPython27.msi /qn /quiet /norestart
If ($lastexitcode -notmatch 0) {
"[ERROR] There were problems when installing VCForPython27.msi"
Exit
}
"[INFO] Removing VCForPython27.msi"
If (Test-Path "VCForPython27.msi") {
Remove-Item VCForPython27.msi
}
# installation of browsers
"[INFO] Installing Chrome"
choco install googlechrome
If ($lastexitcode -notmatch 0) {
"[ERROR] There were problems when installing Chrome"
Exit
}
If (Test-Path "C:\Program Files\Google\Chrome\Application\") {
Add-EnvPath "C:\Program Files\Google\Chrome\Application\"
} ElseIf (Test-Path "C:\Program Files (x86)\Google\Chrome\Application\") {
Add-EnvPath "C:\Program Files (x86)\Google\Chrome\Application\"
}
"[INFO] Installing Firefox"
choco install firefox -y
If ($lastexitcode -notmatch 0) {
"[ERROR] There were problems when installing Firefox"
Exit
}
If (Test-Path "C:\Program Files\Mozilla Firefox") {
Add-EnvPath "C:\Program Files\Mozilla Firefox"
} ElseIf (Test-Path "C:\Program Files (x86)\Mozilla Firefox") {
Add-EnvPath "C:\Program Files (x86)\Mozilla Firefox"
}
# installation of sikuli
"[INFO] Installing SikuliX 1.1.0"
choco install sikulix
If ($lastexitcode -notmatch 0) {
"[ERROR] There were problems when installing SikuliX"
Exit
}
########################
# #
# Hasal Setup #
# #
########################
"[INFO] Creating Miniconda virtualenv (It might take some time to finish.)"
conda config --set always_yes yes --set changeps1 no
conda install psutil
conda create -q -n env-python python=2.7 numpy scipy nose pywin32 pip matplotlib==1.5.3 runipy==0.1.5
Copy-Item C:\ProgramData\chocolatey\lib\sikulix\content\* .\thirdParty\
Copy-Item .\scripts\runsikuli* .\thirdParty\
CMD /C "$CondaPath\envs\env-python\Scripts\pip" install mitmproxy
CMD /C "$CondaPath\envs\env-python\Scripts\pip" install thirdParty\opencv_python-2.4.13-cp27-cp27m-win32.whl
CMD /C "$CondaPath\envs\env-python\Scripts\pip" install thirdParty\opencv_python-2.4.13.2-cp27-cp27m-win_amd64.whl
CMD /C "$CondaPath\envs\env-python\Scripts\pip" install -r requirements.txt
CMD /C "$CondaPath\envs\env-python\Scripts\pip" install -r ejenti\requirements.txt
CMD /C certutil -p "" thirdParty\mitmproxy-ca-cert.p12
CMD /C "$CondaPath\envs\env-python\python" setup.py install
CMD /C "$CondaPath\envs\env-python\python" scripts\cv2_checker.py
########################
# #
# User Interactions #
# #
########################
# OBS License Agreement
IF ($FIRST_OBS) {
If (Test-Path "C:\Program Files (x86)\obs-studio\bin\32bit\obs32.exe") {
pushd "C:\Program Files (x86)\obs-studio\bin\32bit\"
"[INFO] Launching OBS for License Agreement."
""
"[INFO] If there is error message about missing MSVCP120.dll,"
"[INFO] please install Visual C++ Redistributable Packages from https://www.microsoft.com/en-us/download/details.aspx?id=40784"
"[INFO] ** Please CLOSE OBS after accepting License Agreement **"
CMD /C obs32.exe
popd
} ELSE {
"[WARN] Can not find OBS binary file."
}
}
"[INFO] You will need to restart the computer so that the PATH will be effective"