Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(407)

Side by Side Diff: config/jenkins/windows/bootstrap-vm.ps1

Issue 322640043: [plaso] Script used to create Jenkins slaves in GCE. (Closed)
Patch Set: +pyinstaller Created 6 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Avoid re-running
2 if (Test-Path -Path $data_directory) {
3 Write-Host 'Tools already present, exiting startup script.'
4 exit
5 }
6
7 ## Set up default URLs and Paths
8 $install_log_path = "$($data_directory)\provision.log"
9 $jenkins_slave_path = "$($jenkins_home_directory)\slave.jar"
10 $vc_for_python_url = 'https://download.microsoft.com/download/7/9/6/796EF2E4-801 B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi'
11 $vc_for_python_path = "$($data_directory)\VCForPython27.msi"
12 $vs_registry_key_path = 'HKLM:\Software\Wow6432Node\Microsoft\VisualStudio\9.0\S etup\VC'
13 $vs_registry_key_value = "C:\Users\$($username)\AppData\Local\Programs\Common\Mi crosoft\Visual C++ for Python\9.0"
14
15 mkdir $data_directory
16
17 ## Download & install Visual Studio for Python
18 echo "Downloading $($vc_for_python_url) to $($vc_for_python_path)" | Tee-Object -Append -FilePath $install_log_path
19 (New-Object System.Net.WebClient).DownloadFile($vc_for_python_url, $vc_for_pytho n_path)
20 echo 'Download complete, now installing' | Tee-Object -Append -FilePath $install _log_path
21 $msiexec_arguments=@"
22 /i $($vc_for_python_path) ROOT="$($vs_registry_key_value)" /qn /L*+ $($install_l og_path)
23 "@
24 Start-Process msiexec.exe -Wait -ArgumentList $msiexec_arguments
25 echo "Adding registry key $($vs_registry_key_path)\productdir with value $($vs_r egistry_key_value)" | Tee-Object -Append -FilePath $install_log_path
26 New-Item $vs_registry_key_path -Force | New-ItemProperty -Name productdir -Value $vs_registry_key_value -Force
27 echo 'Installing Microsoft Visual C++ Compiler for Python 2.7... done!' | Tee-Ob ject -Append -FilePath $install_log_path
28
29 ## Download & install Chocolatey
30 echo 'Installing Chocolatey' | Tee-Object -Append -FilePath $install_log_path
31 iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/in stall.ps1'))
32 #
33 ## Set up SSHd
34 $user_dirs = Get-ChildItem "C:\Users\$($username)*"
35 $user_dir = $user_dirs[0].FullName
36 $ssh_user_directory = "$($user_dir)\.ssh"
37 $authorized_keys_path = "$($ssh_user_directory)\authorized_keys"
38 mkdir $ssh_user_directory | Tee-Object -Append -FilePath $install_log_path
39
40 echo 'Installing SSHd' | Tee-Object -Append -FilePath $install_log_path
41 Choco install openssh -y --force --params '"/SSHServerFeature"' | Tee-Object -Ap pend -FilePath $install_log_path
42 echo "Write public key to $($authorized_keys_path) file" | Tee-Object -Append -F ilePath $install_log_path
43 Set-content -Path $authorized_keys_path -Encoding ASCII -Value $pub_key_content
44
45 echo 'Give read access to SSHd' | Tee-Object -Append -FilePath $install_log_path
46 $Acl = Get-Acl $authorized_keys_path
47 $Ar = New-Object system.security.accesscontrol.filesystemaccessrule("NT SERVICE\ sshd","Read","Allow")
48 $Acl.SetAccessRule($Ar)
49 Set-Acl $authorized_keys_path $Acl
50
51 echo "Remove extra permissions on $($authorized_keys_path)" | Tee-Object -Append -FilePath $install_log_path
52 .\icacls.exe $($authorized_keys_path) /inheritance:d
53 .\icacls.exe $($authorized_keys_path) /remove Everyone
54 .\icacls.exe $($authorized_keys_path) /remove BUILTIN\Users
55
56 echo "New ACLs for $($authorized_keys_path):" | Tee-Object -Append -FilePath $in stall_log_path
57 Get-Acl $authorized_keys_path | Tee-Object -Append -FilePath $install_log_path
58
59 ## Install plaso dependencies
60 Choco install patch -y | Tee-Object -Append -FilePath $install_log_path # Used w hen building plaso dependencies
61 Choco install jre8 -y | Tee-Object -Append -FilePath $install_log_path # Needed for jenkins client
62 Choco install git -y --params '"/GitAndUnixToolsOnPath"' | Out-Null #Tee-Object -Append -FilePath $install_log_path
63 Choco install python2 -y | Tee-Object -Append -FilePath $install_log_path
64 # Pip package is broken as per 2017-07-14
65 Choco install pip -y --allow-empty-checksums | Tee-Object -Append -FilePath $ins tall_log_path
66 Choco install vcredist2010 -y | Tee-Object -Append -FilePath $install_log_path
67
68 c:\python27\scripts\pip.exe install wmi | Tee-Object -Append -FilePath $install_ log_path
69 c:\python27\scripts\pip.exe install pypiwin32 | Tee-Object -Append -FilePath $in stall_log_path
70 c:\python27\scripts\pip.exe install requests | Tee-Object -Append -FilePath $ins tall_log_path
71 c:\python27\scripts\pip.exe install pyinstaller | Tee-Object -Append -FilePath $ install_log_path
72
73 echo 'Downloading Jenkins client' | Tee-Object -Append -FilePath $install_log_pa th
74 mkdir $jenkins_home_directory
75 (New-Object System.Net.WebClient).DownloadFile($jenkins_slave_url, $jenkins_slav e_path)
76
77 # Disable stupid UAC
78 New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies \System" -Name EnableInstallerDetection -Value 0 -Force
79 # This needs a reboot to be applied
80
81 Restart-Computer
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b