|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Apoxy installer |
| 4 | +# |
| 5 | +# Usage: |
| 6 | +# curl -fsSL https://raw.githubusercontent.com/apoxy-dev/apoxy-cli/master/scripts/install.sh | bash |
| 7 | + |
| 8 | +# When releasing Apoxy, the releaser should update this version number |
| 9 | +# AFTER they upload new binaries. |
| 10 | +VERSION="0.1.1" |
| 11 | + |
| 12 | +set -e |
| 13 | + |
| 14 | +function copy_binary() { |
| 15 | + if [[ ":$PATH:" == *":$HOME/bin:"* ]]; then |
| 16 | + if [ ! -d "$HOME/bin" ]; then |
| 17 | + mkdir -p "$HOME/bin" |
| 18 | + fi |
| 19 | + mv apoxy "$HOME/bin/apoxy" |
| 20 | + else |
| 21 | + echo "Installing Apoxy to /usr/local/bin which is write protected" |
| 22 | + echo "If you'd prefer to install Apoxy without sudo permissions, add \$HOME/bin to your \$PATH and rerun the installer" |
| 23 | + sudo mv apoxy /usr/local/bin/apoxy |
| 24 | + fi |
| 25 | +} |
| 26 | + |
| 27 | +function install_apoxy() { |
| 28 | + if [[ "$OSTYPE" == "linux"* ]]; then |
| 29 | + # On Linux, "uname -m" reports "aarch64" on ARM 64 bits machines, |
| 30 | + # and armv7l on ARM 32 bits machines like the Raspberry Pi. |
| 31 | + # This is a small workaround so that the install script works on ARM. |
| 32 | + case $(uname -m) in |
| 33 | + aarch64) ARCH=arm64;; |
| 34 | + armv7l) ARCH=arm;; |
| 35 | + *) ARCH=$(uname -m);; |
| 36 | + esac |
| 37 | + set -x |
| 38 | + curl -fsSL https://github.com/apoxy-dev/apoxy-cli/releases/download/v$VERSION/apoxy_Linux_$ARCH.tar.gz | tar -xzv apoxy |
| 39 | + copy_binary |
| 40 | + elif [[ "$OSTYPE" == "darwin"* ]]; then |
| 41 | + # On macOS, "uname -m" reports "arm64" on ARM 64 bits machines |
| 42 | + ARCH=$(uname -m) |
| 43 | + set -x |
| 44 | + curl -fsSL https://github.com/apoxy-dev/apoxy-cli/releases/download/v$VERSION/apoxy_Darwin_$ARCH.tar.gz | tar -xzv apoxy |
| 45 | + copy_binary |
| 46 | + else |
| 47 | + set +x |
| 48 | + echo "The Tilt installer does not work for your platform: $OSTYPE" |
| 49 | + echo "" |
| 50 | + echo "If you think your platform should be supported, please file an issue:" |
| 51 | + echo "https://github.com/apoxy-dev/apoxy-cli/issues/new" |
| 52 | + echo "Thank you!" |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + |
| 56 | + set +x |
| 57 | +} |
| 58 | + |
| 59 | +# so that we can skip installation in CI and just test the version check |
| 60 | +if [[ -z $NO_INSTALL ]]; then |
| 61 | + install_apoxy |
| 62 | +fi |
| 63 | + |
| 64 | +echo "Apoxy installed!" |
0 commit comments