forked from stream-labs/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-ci.ps1
83 lines (64 loc) · 3.35 KB
/
install-ci.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
# Run this script as administrator to setup enviroment on new CI machine:
# powershell install.ps1 your_azure_token host_user host_password agent_pool?
$token=$args[0]
$username=$args[1]
$password=$args[2]
$pool=$args[3]
if (-Not $pool) { $pool = 'Default' }
$agentPath = "C:\agent\run.cmd"
if (-Not($token) -Or -Not($username) -Or -Not($password)) {
echo "Provide a token, system user name and password";
echo "Installation canceled";
exit;
}
echo "Install Chocolately"
if (-NOT(Get-Command "choco" -errorAction SilentlyContinue)) {
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'));
choco feature enable -n allowGlobalConfirmation
}
echo "Install Visual C++ Redistributable (required for node-win32-np module)"
choco install vcredist2015
echo "Install Nodejs"
choco install nodejs --version=10.15.3
echo "Install Yarn"
choco install yarn
echo "Install Git for Windows"
choco install git.install
git config --global core.autocrlf false # setup line-ednings transform
echo "Install 7zip"
choco install 7zip
echo "Install CMake"
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
echo "Install Visual Studio 2017 Build Tools"
choco install visualstudio2017buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools;includeRecommended;includeOptional"
echo "Donwload and install Azure Agent"
cd /
Remove-Item -Recurse -Force -ErrorAction Ignore agent
mkdir agent ; cd agent;
Invoke-WebRequest -Uri https://vstsagentpackage.azureedge.net/agent/2.150.3/vsts-agent-win-x64-2.150.3.zip -OutFile "$PWD\agent.zip"
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD\agent.zip", "$PWD")
echo "Configure Azure Agent"
$publicIp = (Invoke-RestMethod ipinfo.io/ip).trim()
.\config --unattended --url https://dev.azure.com/streamlabs --auth pat --token $token --agent "$env:computername $publicIp" --pool $pool
# Disable the lock screen to prevent the PC locking after the end of the RDP session
Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" -Name 'NoLockScreen' -Value 1;
# Azure Agent has --AutoLogon option to add Anget to autostartup
# But it doesn't allow to pass any arguments to the Agent
# So call own implementation of AutoLogon here
echo "Setup auto-login when system starts"
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
Set-ItemProperty $RegPath "AutoAdminLogon" -Value "1" -type String
Set-ItemProperty $RegPath "DefaultUsername" -Value $username -type String
Set-ItemProperty $RegPath "DefaultPassword" -Value "$password" -type String
# Setup WinRM for remote connections
# Trusted hosts and ports must be confgured on the level above
# Use the example below to run scripts on several agents:
# $LiveCred = Get-Credential
# Invoke-Command -Computer Agent1, Agent2, Agent3 -Credential $LiveCred -ScriptBlock {Get-Process}
Enable-PSRemoting -Force
Set-Item -Force wsman:\localhost\client\trustedhosts *
New-NetFirewallRule -DisplayName "Allow inbound TCP port 5985" -Direction inbound -LocalPort 5985 -Protocol TCP -Action Allow
Restart-Service WinRM
echo "Add agent to startup"
Set-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run" -Name 'StartAsureAgent' -Value $agentPath;
echo "Installation completed. Restart PC to take effect"