#!/bin/sh # hproxy, HProxy's command-line tool 0.2.8: https://hproxy.com/tools/ai # Usage: curl -fsSL https://hproxy.com/install.sh | sh # Puts one file, hproxy, in ~/.local/bin (or $HPROXY_INSTALL_DIR) after checking its SHA-256. # Everything runs from main, on the last line, so a download cut short runs nothing. set -eu main() { version="0.2.8" base="https://hproxy.com/downloads/cli/0.2.8" os=$(uname -s) arch=$(uname -m) # A Terminal under Rosetta says x86_64 on an Apple Silicon Mac: the native file is the right one. if [ "$os" = Darwin ] && [ "$arch" = x86_64 ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" = 1 ]; then arch=arm64 fi case "$os/$arch" in Darwin/arm64) file="hproxy-cli-macos-arm64"; sum="55b7059e064c564f5aa1187a7af99716b1e01da05be2d6cd04b5d85015148e95" ;; Darwin/x86_64) file="hproxy-cli-macos-x86_64"; sum="46005b5f230e0ae3c817f0ab2c8de5260c1699a62b0f91b58bf9329cda248c9c" ;; Linux/x86_64 | Linux/amd64) file="hproxy-cli-linux-x86_64"; sum="6ee3bcb7ba038d34c5dc6b5bc1c4c0e8081ae8c54cbe1748edd7573f4b0073b3" ;; Linux/aarch64 | Linux/arm64) file="hproxy-cli-linux-arm64"; sum="dbdeae28c0894dc70d4bcb2ac5e5c03e77c849a0ca7698b4741cdf77bb2d02d8" ;; Linux/armv6l | Linux/armv7l | Linux/armv8l) file="hproxy-cli-linux-armv6"; sum="1a67176a38bb8068ed9688510c5a837da91ee6ffd9c42972bd87c0129ab998f7" ;; *) echo "hproxy: there is no build for $os $arch yet. On Windows, in PowerShell: irm https://hproxy.com/install.ps1 | iex" >&2 exit 1 ;; esac if command -v sha256sum > /dev/null 2>&1; then hasher="sha256sum" elif command -v shasum > /dev/null 2>&1; then hasher="shasum -a 256" else echo "hproxy: there is no sha256sum or shasum here to check the download. Nothing was installed." >&2 exit 1 fi dir="${HPROXY_INSTALL_DIR:-$HOME/.local/bin}" mkdir -p "$dir" tmp=$(mktemp "$dir/.hproxy.XXXXXX") || { echo "hproxy: cannot write to $dir." >&2; exit 1; } trap 'rm -f "$tmp"' EXIT trap 'exit 1' HUP INT TERM echo "Downloading hproxy $version ($file)..." curl -fsSL "$base/$file" -o "$tmp" # From stdin, so no file name is printed beside the sum (sha256sum escapes unusual names). got=$($hasher < "$tmp" | cut -d ' ' -f 1) if [ "$got" != "$sum" ]; then echo "hproxy: the download does not match its SHA-256. Nothing was installed." >&2 exit 1 fi chmod 755 "$tmp" mv -f "$tmp" "$dir/hproxy" trap - EXIT HUP INT TERM echo "Installed: $dir/hproxy" "$dir/hproxy" --version || true case ":$PATH:" in *":$dir:"*) ;; *) echo "$dir is not on your PATH yet. Add it, for example in ~/.zshrc or ~/.bashrc:" echo " export PATH=\"$dir:\$PATH\"" ;; esac echo "Try: hproxy list --country DE --protocol socks5 --limit 5" } main "$@"