diff --git a/scripts/install.ps1 b/scripts/install.ps1 index b7f859d..ee679b8 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -9,12 +9,15 @@ param( $ErrorActionPreference = "Stop" -$exeName = "ir" + $repository = "smashedr/install-release" +$exeName = "ir" -Write-Host -ForegroundColor Green "Installing: $repository" -## ARCH +Write-Host -ForegroundColor Green "Installing: $repository as $exeName" + + +## OS if (-not (Test-Path variable:IsWindows)) { Write-Host -ForegroundColor DarkCyan "Windows Detected. Forcing IsWindows." $script:IsWindows = $true @@ -29,6 +32,9 @@ $platform = switch ($true) { } } Write-Host -ForegroundColor DarkCyan "platform: $platform" + + +## ARCH $osArchitecture = [System.Runtime.InteropServices.RuntimeInformation,mscorlib]::OSArchitecture Write-Host -ForegroundColor DarkCyan "osArchitecture: $osArchitecture" $arch = switch ($osArchitecture) { @@ -42,6 +48,7 @@ $arch = switch ($osArchitecture) { } Write-Host -ForegroundColor DarkCyan "arch: $arch" + ## FILE if ($IsWindows) { $binPath = Join-Path $env:LOCALAPPDATA "Microsoft\WindowsApps" @@ -54,9 +61,13 @@ if ($IsWindows) { Write-Host -ForegroundColor DarkCyan "exeName: $exeName" Write-Host -ForegroundColor DarkCyan "binPath: $binPath" Write-Host -ForegroundColor DarkCyan "file: $file" + + +## URL $url = "https://github.com/$repository/releases/latest/download/$file" Write-Host -ForegroundColor DarkCyan "url: $url" + ## BIN Write-Host -ForegroundColor White "Target Directory: $binPath" if ($bin) { @@ -75,6 +86,7 @@ if (-not (Test-Path $binPath)) { throw } + ## PATH if ($IsWindows) { # Windows @@ -103,6 +115,7 @@ if ($IsWindows) { } } + ## TEMP $temp = [system.io.path]::GetTempPath() Write-Host -ForegroundColor DarkCyan "temp: $temp" @@ -111,19 +124,21 @@ Write-Host -ForegroundColor DarkCyan "tempDir: $tempDir" $zipPath = Join-Path $tempDir $file Write-Host -ForegroundColor DarkCyan "zipPath: $zipPath" -## EXEC + try { # Download Write-Host -ForegroundColor DarkCyan "Downloading: $url" New-Item -ItemType Directory -Path $tempDir -Force | Out-Null Invoke-WebRequest -Uri $url -OutFile $zipPath + # Extract if ($zipPath -like "*.tar.gz") { tar -xzf $zipPath -C $tempDir } else { Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force } - # Install + + # Move $source = Join-Path $tempDir $exeName Move-Item -Path $source -Destination $binPath -Force } catch { diff --git a/scripts/install.sh b/scripts/install.sh index 40aba83..043a076 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -4,13 +4,12 @@ set -e -OWNER="smashedr" -REPO="install-release" +REPOSITORY="smashedr/install-release" EXE="ir" -TARGET_BIN="${HOME}/bin" +#TARGET_BIN="${HOME}/bin" -echo "Installing: ${OWNER}/${REPO} as ${EXE}" +echo "Installing: ${REPOSITORY} as ${EXE}" function fail() { @@ -24,7 +23,7 @@ function fail() { } -# OS +## OS OS=$(uname -s | tr '[:upper:]' '[:lower:]') echo "OS: ${OS}" case "${OS}" in @@ -36,7 +35,7 @@ esac echo "OS: ${OS}" -# ARCH +## ARCH ARCH="$(uname -m)" echo "ARCH: ${ARCH}" case "${ARCH}" in @@ -48,12 +47,14 @@ esac echo "ARCH: ${ARCH}" -# FTYPE +## FILE if [[ "${OS}" = "Windows" ]]; then + TARGET_BIN="${LOCALAPPDATA}\Microsoft\WindowsApps" # TODO: Confirm setting ${EXE} to .exe is not required FTYPE="zip" which unzip > /dev/null || fail "unzip is not installed" else + TARGET_BIN="${HOME}/.local/bin" FTYPE="tar.gz" which tar > /dev/null || fail "tar is not installed" which gzip > /dev/null || fail "gzip is not installed" @@ -61,12 +62,12 @@ fi echo "FTYPE: ${FTYPE}" -# URL -URL="https://github.com/${OWNER}/${REPO}/releases/latest/download/${EXE}_${OS}_${ARCH}.${FTYPE}" +## URL +URL="https://github.com/${REPOSITORY}/releases/latest/download/${EXE}_${OS}_${ARCH}.${FTYPE}" echo "URL: ${URL}" -# GET +## GET GET="" if which curl > /dev/null; then GET="curl --fail -# -L" @@ -81,7 +82,7 @@ fi echo "GET: ${GET}" -# BIN +## BIN echo "Target Directory: ${TARGET_BIN}" echo -n "Enter Path [press to accept]: " read -r input