#!/bin/bash # Script to install the Porter CLI on macOS, Linux, and WSL osname="" arch=$(arch) check_prereqs() { command -v curl >/dev/null 2>&1 || { echo "[ERROR] curl is required to install the Porter CLI." >&2; exit 1; } command -v unzip >/dev/null 2>&1 || { echo "[ERROR] unzip is required to install the Porter CLI." >&2; exit 1; } } download_and_install() { check_prereqs echo "[INFO] Since the Porter CLI gets installed in /usr/local/bin, you may be asked to input your password." echo "[INFO] Please make sure /usr/local/bin is included in your PATH." porter_version="0.65.10" if [[ -n "$PORTER_VERSION" ]]; then echo "[INFO] Using $PORTER_VERSION override instead of $porter_version" porter_version="$PORTER_VERSION" fi curl -L "https://github.com/porter-dev/releases/releases/download/v${porter_version}/porter_${porter_version}_${osname}_${arch}" --output porter-cli-executable chmod +x ./porter-cli-executable sudo mv ./porter-cli-executable /usr/local/bin/porter command -v porter >/dev/null 2>&1 || { echo "[ERROR] There was an error installing the Porter CLI. Please try again." >&2; exit 1; } # only for legacy support (switchboard required) curl -L "https://github.com/porter-dev/releases/releases/download/v${porter_version}/docker-credential-porter_${porter_version}_${osname}_${arch}" --output docker-credential-porter chmod +x ./docker-credential-porter sudo mv ./docker-credential-porter /usr/local/bin/docker-credential-porter exit } if [[ "$arch" == "x86_64" ]]; then arch="amd64" elif [[ "$arch" == "aarch64" ]]; then arch="arm64" fi if [[ "$OSTYPE" == "linux-gnu"* ]]; then if uname -a | grep -q '^Linux.*Microsoft'; then echo "[WARNING] WSL support is experimental and may result in crashes." fi osname="linux" download_and_install elif [[ "$OSTYPE" == "darwin"* ]]; then osname="darwin" download_and_install fi echo "[ERROR] Unsupported operating system." exit 1