Start osqueryd on install with chocolatey (#3185)

This commit is contained in:
ryanheffernan 2017-04-20 18:25:07 -07:00 committed by Nick Anderson
parent 13aef1fb73
commit 0b8db4c67c

View File

@ -54,16 +54,19 @@ Get-ChocolateyUnzip -FileFullPath $packagePath -Destination $targetFolder
Move-Item -Force -Path $targetDaemonBin -Destination $destDaemonBin
Set-DenyWriteAcl $daemonFolder 'Add'
if ($installService -and (-not (Get-Service $serviceName -ErrorAction SilentlyContinue))) {
Write-Debug '[+] Installing osquery daemon service.'
# If the 'install' parameter is passed, we create a Windows service with
# the flag file in the default location in \ProgramData\osquery\
New-Service -Name $serviceName -BinaryPathName "$destDaemonBin --flagfile=\ProgramData\osquery\osquery.flags" -DisplayName $serviceName -Description $serviceDescription -StartupType Automatic
if ($installService) {
if (-not (Get-Service $serviceName -ErrorAction SilentlyContinue)) {
Write-Debug '[+] Installing osquery daemon service.'
# If the 'install' parameter is passed, we create a Windows service with
# the flag file in the default location in \ProgramData\osquery\
New-Service -Name $serviceName -BinaryPathName "$destDaemonBin --flagfile=\ProgramData\osquery\osquery.flags" -DisplayName $serviceName -Description $serviceDescription -StartupType Automatic
# If the osquery.flags file doesn't exist, we create a blank one.
if (-not (Test-Path "$targetFolder\osquery.flags")) {
Add-Content "$targetFolder\osquery.flags" $null
# If the osquery.flags file doesn't exist, we create a blank one.
if (-not (Test-Path "$targetFolder\osquery.flags")) {
Add-Content "$targetFolder\osquery.flags" $null
}
}
Start-Service $serviceName
}
# Add osquery binary path to machines path for ease of use.