2
0

install.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # Script to install the Porter CLI on macOS, Linux, and WSL
  3. osname=""
  4. check_prereqs() {
  5. command -v curl >/dev/null 2>&1 || { echo "[ERROR] curl is required to install the Porter CLI." >&2; exit 1; }
  6. command -v unzip >/dev/null 2>&1 || { echo "[ERROR] unzip is required to install the Porter CLI." >&2; exit 1; }
  7. }
  8. download_and_install() {
  9. check_prereqs
  10. echo "[INFO] Since the Porter CLI gets installed in /usr/local/bin, you may be asked to input your password."
  11. echo "[INFO] Please make sure /usr/local/bin is included in your PATH."
  12. curl -L https://github.com/porter-dev/porter/releases/download/{{ .TagName }}/porter_{{ .TagName }}_${osname}_x86_64.zip --output porter.zip
  13. unzip -o -a porter.zip
  14. rm porter.zip
  15. chmod +x ./porter
  16. sudo mv ./porter /usr/local/bin/porter
  17. command -v porter >/dev/null 2>&1 || { echo "[ERROR] There was an error installing the Porter CLI. Please try again." >&2; exit 1; }
  18. exit
  19. }
  20. if [[ "$OSTYPE" == "linux-gnu"* ]]; then
  21. if uname -a | grep -q '^Linux.*Microsoft'; then
  22. echo "[WARNING] WSL support is experimental and may result in crashes."
  23. fi
  24. osname="Linux"
  25. download_and_install
  26. elif [[ "$OSTYPE" == "darwin"* ]]; then
  27. osname="Darwin"
  28. download_and_install
  29. fi
  30. echo "[ERROR] Unsupported operating system."
  31. exit 1