mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 18:08:53 +00:00
parent
e3efde68d8
commit
0ef97d1acc
@ -5,6 +5,10 @@
|
||||
# LICENSE file in the root directory of this source tree. An additional grant
|
||||
# of patent rights can be found in the PATENTS file in the same directory.
|
||||
|
||||
# We make heavy use of Write-Host, because colors are awesome. #dealwithit.
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", '', Scope="Function", Target="*")]
|
||||
param()
|
||||
|
||||
# URL of where our pre-compiled third-party dependenices are archived
|
||||
$THIRD_PARTY_ARCHIVE_URL = 'https://osquery-packages.s3.amazonaws.com/choco'
|
||||
|
||||
@ -15,6 +19,22 @@ function Test-IsAdmin {
|
||||
)
|
||||
}
|
||||
|
||||
function Test-RebootPending {
|
||||
$compBasedServ = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -ErrorAction Ignore
|
||||
$winUpdate = Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -ErrorAction Ignore
|
||||
$ccm = $false
|
||||
try {
|
||||
$util = [wmiclass]"\\.\root\ccm\clientsdk:CCM_ClientUtilities"
|
||||
$status = $util.DetermineIfRebootPending()
|
||||
if(($null -ne $status) -and $status.RebootPending){
|
||||
$ccm = $true
|
||||
}
|
||||
} catch {
|
||||
$ccm = $false
|
||||
}
|
||||
return $compBasedServ -or $winUpdate -or $ccm
|
||||
}
|
||||
|
||||
# Checks if a package is already installed through chocolatey
|
||||
# Returns true if:
|
||||
# * The package is installed and the user supplies no version
|
||||
@ -50,7 +70,7 @@ function Install-PowershellLinter {
|
||||
|
||||
$nugetProviderInstalled = $false
|
||||
Write-Host " => Determining whether NuGet package provider is already installed." -foregroundcolor DarkYellow
|
||||
foreach ($provider in Get-PackageProvider -ListAvailable) {
|
||||
foreach ($provider in Get-PackageProvider) {
|
||||
if ($provider.Name -eq "NuGet" -and $provider.Version -ge 2.8.5.206) {
|
||||
$nugetProviderInstalled = $true
|
||||
break
|
||||
@ -129,6 +149,9 @@ function Install-ChocoPackage {
|
||||
$args += ${packageOptions}
|
||||
}
|
||||
choco ${args}
|
||||
if (@(3010,2147781575,-2147185721,-2147205120) -Contains $LastExitCode){
|
||||
$LastExitCode = 0
|
||||
}
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Host "[-] ERROR: $packageName $packageVersion failed to install!" -foregroundcolor Red
|
||||
Exit -1
|
||||
@ -157,13 +180,13 @@ function Install-PipPackage {
|
||||
}
|
||||
$requirements = Resolve-Path ([System.IO.Path]::Combine($PSScriptRoot, '..', 'requirements.txt'))
|
||||
Write-Host " => Upgrading pip..." -foregroundcolor DarkYellow
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip -q install --upgrade pip
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Host "[-] ERROR: pip upgrade failed." -foregroundcolor Red
|
||||
Exit -1
|
||||
}
|
||||
Write-Host " => Installing from requirements.txt" -foregroundcolor DarkYellow
|
||||
pip install -r $requirements.path
|
||||
pip -q install -r $requirements.path
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Host "[-] ERROR: Install packages from requirements failed." -foregroundcolor Red
|
||||
Exit -1
|
||||
@ -257,14 +280,14 @@ function Update-GitSubmodule {
|
||||
$thirdPartyPath = Resolve-Path ([System.IO.Path]::Combine($PSScriptRoot, '..', 'third-party'))
|
||||
Write-Host " => Updating git submodules in $thirdPartyPath ..." -foregroundcolor Yellow
|
||||
Push-Location $thirdPartyPath
|
||||
git submodule update --init
|
||||
git submodule --quiet update --init
|
||||
Pop-Location
|
||||
Write-Host "[+] Submodules updated!" -foregroundcolor Yellow
|
||||
}
|
||||
|
||||
function Main {
|
||||
if ($PSVersionTable.PSVersion.Major -lt 5.0 ) {
|
||||
Write-Output "This installer requires Powershell 5.0 or Greater."
|
||||
if ($PSVersionTable.PSVersion.Major -lt 3.0 ) {
|
||||
Write-Output "This installer currently requires Powershell 3.0 or greater."
|
||||
Exit -1
|
||||
}
|
||||
|
||||
@ -275,18 +298,26 @@ function Main {
|
||||
Exit -1
|
||||
}
|
||||
Write-Host "[+] Success!" -foregroundcolor Green
|
||||
Install-Chocolatey
|
||||
Install-ChocoPackage 'cppcheck'
|
||||
Install-ChocoPackage '7zip.commandline'
|
||||
Install-ChocoPackage 'cmake.portable' '3.6.1'
|
||||
Install-ChocoPackage 'python2' '2.7.11'
|
||||
Install-PipPackage
|
||||
Update-GitSubmodule
|
||||
$out = Install-Chocolatey
|
||||
$out = Install-ChocoPackage 'cppcheck'
|
||||
$out = Install-ChocoPackage '7zip.commandline'
|
||||
$out = Install-ChocoPackage 'cmake.portable' '3.6.1'
|
||||
$out = Install-ChocoPackage 'python2' '2.7.11'
|
||||
$out = Install-PipPackage
|
||||
$out = Update-GitSubmodule
|
||||
$deploymentFile = Resolve-Path ([System.IO.Path]::Combine($PSScriptRoot, 'vsdeploy.xml'))
|
||||
$chocoParams = @("--execution-timeout", "7200", "-packageParameters", "--AdminFile ${deploymentFile}")
|
||||
Install-ChocoPackage 'visualstudio2015community' '' ${chocoParams}
|
||||
Install-ThirdParty
|
||||
Install-PowershellLinter
|
||||
$out = Install-ChocoPackage 'visualstudio2015community' '' ${chocoParams}
|
||||
if(Test-RebootPending -eq $true) {
|
||||
Write-Host "*** Windows requires a reboot to complete installing Visual Studio. Please reboot your system and re-run this provisioning script. ***" -foregroundcolor yellow
|
||||
Exit 0
|
||||
}
|
||||
$out = Install-ThirdParty
|
||||
if ($PSVersionTable.PSVersion.Major -lt 5.1 ) {
|
||||
Write-Host "[*] Powershell version is < 5.1. Skipping Powershell Linter Installation." -foregroundcolor yellow
|
||||
} else {
|
||||
$out = Install-PowershellLinter
|
||||
}
|
||||
Write-Host "[+] Done." -foregroundcolor Yellow
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user