From b4742983523656d2d12ec89ddf3cbe78282e54e8 Mon Sep 17 00:00:00 2001 From: Thibault Le Ouay Ducasse Date: Sat, 31 Jan 2026 22:04:31 +0100 Subject: [PATCH] fix install script --- install.ps1 | 23 ++++++++++++++++++++--- install.sh | 31 +++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 9 deletions(-) mode change 100644 => 100755 install.sh diff --git a/install.ps1 b/install.ps1 index 61c8c1b..ede4dca 100644 --- a/install.ps1 +++ b/install.ps1 @@ -20,7 +20,14 @@ $BinDir = if ($OpenstatusInstall) { } $OpenstatusExe = "$BinDir\openstatus.exe" -$Target = 'win-x64' + +# Detect architecture +$Arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture +$Target = switch ($Arch) { + "Arm64" { "Windows_arm64" } + "X86" { "Windows_i386" } + default { "Windows_x86_64" } +} $Version = if (!$Version) { curl.exe --ssl-revoke-best-effort -s "https://api.github.com/repos/openstatusHQ/cli/releases/latest" | @@ -32,13 +39,23 @@ $Version = if (!$Version) { Write-Output "Installing openstatus ${Version} for ${Target}" -$DownloadUrl = "https://github.com/openstatusHQ/cli/releases/download/${Version}/openstatus-${Target}.exe" +$DownloadUrl = "https://github.com/openstatusHQ/cli/releases/download/${Version}/cli_${Target}.zip" if (!(Test-Path $BinDir)) { New-Item $BinDir -ItemType Directory | Out-Null } -curl.exe --ssl-revoke-best-effort -Lo $OpenstatusExe $DownloadUrl +# Download and extract the zip file +$TempDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP ([System.IO.Path]::GetRandomFileName())) +$ZipFile = Join-Path $TempDir "openstatus.zip" + +try { + curl.exe --ssl-revoke-best-effort -Lo $ZipFile $DownloadUrl + Expand-Archive -Path $ZipFile -DestinationPath $TempDir -Force + Move-Item -Path (Join-Path $TempDir "openstatus.exe") -Destination $OpenstatusExe -Force +} finally { + Remove-Item -Path $TempDir -Recurse -Force -ErrorAction SilentlyContinue +} $User = [System.EnvironmentVariableTarget]::User $Path = [System.Environment]::GetEnvironmentVariable('Path', $User) diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 6bc5126..1e1e6db --- a/install.sh +++ b/install.sh @@ -6,11 +6,13 @@ set -e if [ "$OS" = "Windows_NT" ]; then - target="win-x64.exe" + target="Windows_x86_64.zip" else case $(uname -sm) in - "Darwin arm64") target="macos-arm" ;; - "Linux x86_64") target="linux-x64" ;; + "Darwin arm64") target="Darwin_arm64.tar.gz" ;; + "Darwin x86_64") target="Darwin_x86_64.tar.gz" ;; + "Linux x86_64") target="Linux_x86_64.tar.gz" ;; + "Linux aarch64") target="Linux_arm64.tar.gz" ;; *) target="unknown" ;; esac fi @@ -76,18 +78,35 @@ if [ -z "$openstatus_version" ]; then openstatus_version=$(get_latest_version) fi -echo "Installing openstatus-${openstatus_version} for ${target}" +platform=$(echo "$target" | sed 's/\.\(tar\.gz\|zip\)$//') +echo "Installing openstatus ${openstatus_version} for ${platform}" -openstatus_uri="https://github.com/openstatusHQ/cli/releases/download/${openstatus_version}/openstatus-${target}" +openstatus_uri="https://github.com/openstatusHQ/cli/releases/download/${openstatus_version}/cli_${target}" openstatus_install="${OPENSTATUS_INSTALL:-$HOME/.openstatus}" bin_dir="$openstatus_install/bin" exe="$bin_dir/openstatus" +echo "Downloading openstatus from $openstatus_uri" if [ ! -d "$bin_dir" ]; then mkdir -p "$bin_dir" fi -curl --fail --location --progress-bar --output "$exe" "$openstatus_uri" +# Download and extract the archive +tmp_dir=$(mktemp -d) +trap "rm -rf $tmp_dir" EXIT + +if echo "$target" | grep -q "\.zip$"; then + # Windows zip file + curl --fail --location --progress-bar --output "$tmp_dir/openstatus.zip" "$openstatus_uri" + unzip -q "$tmp_dir/openstatus.zip" -d "$tmp_dir" + mv "$tmp_dir/openstatus.exe" "$exe" +else + # Unix tar.gz file + curl --fail --location --progress-bar --output "$tmp_dir/openstatus.tar.gz" "$openstatus_uri" + tar -xzf "$tmp_dir/openstatus.tar.gz" -C "$tmp_dir" + mv "$tmp_dir/openstatus" "$exe" +fi + chmod +x "$exe" echo "openstatus was installed successfully to $exe" -- 2.51.2