Skip to content

Commit

Permalink
Adding checks for chocolatey install (osquery#2978)
Browse files Browse the repository at this point in the history
  • Loading branch information
PoppySeedPlehzr authored Feb 7, 2017
1 parent 0e57003 commit f9e1306
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/deployment/chocolatey/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ $destClientBin = Join-Path $targetFolder 'osqueryi.exe'
$packageParameters = $env:chocolateyPackageParameters
$arguments = @{}

# Before modifying we ensure to stop the service, if it exists
if ((Get-Service $serviceName -ErrorAction SilentlyContinue) -and (Get-Service $serviceName).Status -eq 'Running') {
Stop-Service $serviceName
}

# Lastly, ensure that the Deny Write ACLs have been removed before modifying
if (Test-Path $daemonFolder) {
Set-DenyWriteAcl $daemonFolder 'Remove'
}

# Now parse the packageParameters using good old regular expression
if ($packageParameters) {
$match_pattern = "\/(?<option>([a-zA-Z]+)):(?<value>([`"'])?([a-zA-Z0-9- _\\:\.]+)([`"'])?)|\/(?<option>([a-zA-Z]+))"
Expand Down

0 comments on commit f9e1306

Please sign in to comment.