Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ tags
.ruby-version
.kitchen/
.kitchen.local.yml
mixlib-install-*.gem
*.gem
15 changes: 9 additions & 6 deletions lib/mixlib/install/generator/bourne/scripts/check_product.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
if test -d "/opt/$project" && test "x$install_strategy" = "xonce"; then
echo "$project installation detected"
echo "install_strategy set to 'once'"
echo "Nothing to install"
exit
fi
# Check for chef-client command in various locations
for path in /hab/pkgs/chef/chef-infra-client/*/*/bin/chef-client "/usr/bin/${project}-client" "/opt/$project/bin/${project}-client"; do
if test -x "$path" 2>/dev/null && test "x$install_strategy" = "xonce"; then
echo "$project installation detected at $path"
echo "install_strategy set to 'once'"
echo "Nothing to install"
exit
fi
done
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,19 @@ function Install-Project {
$install_strategy
)

if ((Test-Path "$env:systemdrive\<%= windows_dir %>\$project\embedded") -and ($install_strategy -eq 'once')) {
Write-Host "$project installation detected"
Write-Host "install_strategy set to 'once'"
Write-Host "Nothing to install"
exit
# Check for chef-client command in various locations
$chef_locations = @(
"$env:systemdrive\hab\pkgs\chef\chef-infra-client\*\*\bin\chef-client.bat",
"$env:systemdrive\<%= windows_dir %>\$project\bin\$project-client.bat"
)
foreach ($path in $chef_locations) {
$resolved = Get-Item $path -ErrorAction SilentlyContinue | Select-Object -First 1
if ($resolved -and (Test-Path $resolved.FullName) -and ($install_strategy -eq 'once')) {
Write-Host "$project installation detected at $($resolved.FullName)"
Write-Host "install_strategy set to 'once'"
Write-Host "Nothing to install"
exit
}
}

# Set http_proxy as env var
Expand Down Expand Up @@ -93,8 +101,8 @@ function Install-Project {
else {
$filename = (([System.Uri]$download_url).AbsolutePath -split '/')[-1]
}
Write-Verbose "Download directory: $download_directory"
Write-Verbose "Filename: $filename"
Write-Host "Download directory: $download_directory"
Write-Host "Filename: $filename"

if (-not (test-path $download_directory)) {
mkdir $download_directory
Expand All @@ -104,31 +112,31 @@ function Install-Project {
$download_destination = join-path $download_directory $filename

if ((test-path $download_destination)) {
Write-Verbose "Found existing installer at $download_destination."
Write-Host "Found existing installer at $download_destination."
if (-not [string]::IsNullOrEmpty($sha256)) {
Write-Verbose "Checksum specified"
Write-Host "Checksum specified"
$valid_checksum = Test-ProjectPackage -Path $download_destination -Algorithm 'SHA256' -Hash $sha256
if ($valid_checksum -eq $true) {
Write-Verbose "Checksum verified, using existing installer."
Write-Host "Checksum verified, using existing installer."
$cached_installer_available=$true # local file OK
$verify_checksum = $false # no need to re-verify checksums
}
else {
Write-Verbose "Checksum mismatch, ignoring existing installer."
Write-Host "Checksum mismatch, ignoring existing installer."
$cached_installer_available=$false # bad local file
$verify_checksum = $false # re-verify checksums
}
}
else {
Write-Verbose "Checksum not specified, existing installer ignored."
Write-Host "Checksum not specified, existing installer ignored."
$cached_installer_available=$false # ignore local file
$verify_checksum = $false # no checksum to compare
}
}

if (-not ($cached_installer_available)) {
if ($pscmdlet.ShouldProcess("$($download_url)", "Download $project")) {
Write-Verbose "Downloading $project from $($download_url) to $download_destination."
Write-Host "Downloading $project from $($download_url) to $download_destination."
Get-WebContent $download_url -filepath $download_destination
}
}
Expand Down