#!/bin/sh # Installs pbxray to $PREFIX/bin (default /usr/local/bin, override with # PREFIX=~/.local ./install.sh). Downloads the release binary for your # OS/arch (VERSION=vX.Y.Z ./install.sh for a specific one, default # latest). # # This is the public installer — there's no source in this repo to fall # back to building from (pbxray's source is closed, see LICENSE). If your # OS/arch isn't one of the three built (linux/amd64, linux/arm64, # darwin/arm64), there's nothing else to try. set -eu repo="pbxray/pbxray-dist" prefix="${PREFIX:-/usr/local}" bindir="$prefix/bin" version="${VERSION:-latest}" os=$(uname -s | tr '[:upper:]' '[:lower:]') arch=$(uname -m) case "$arch" in x86_64 | amd64) arch=amd64 ;; arm64 | aarch64) arch=arm64 ;; esac case "$os/$arch" in linux/amd64 | linux/arm64 | darwin/arm64) ;; *) echo "install.sh: no pbxray build for $os/$arch" >&2 exit 1 ;; esac asset="pbxray_${os}_${arch}" if [ "$version" = "latest" ]; then url="https://github.com/$repo/releases/latest/download/$asset" else url="https://github.com/$repo/releases/download/$version/$asset" fi tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT echo "downloading $url" curl -fsSL -o "$tmp/pbxray" "$url" chmod +x "$tmp/pbxray" mkdir -p "$bindir" install -m 755 "$tmp/pbxray" "$bindir/pbxray" echo "installed $bindir/pbxray" "$bindir/pbxray" version