install.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/sh
  2. set -e
  3. if [ -z "${BIN_DIR}" ]; then
  4. BIN_DIR=$(pwd)
  5. fi
  6. THE_ARCH_BIN=""
  7. DEST=${BIN_DIR}/frankenphp
  8. OS=$(uname -s)
  9. ARCH=$(uname -m)
  10. if type "tput" >/dev/null 2>&1; then
  11. bold=$(tput bold || true)
  12. italic=$(tput sitm || true)
  13. normal=$(tput sgr0 || true)
  14. fi
  15. case ${OS} in
  16. Linux*)
  17. case ${ARCH} in
  18. aarch64)
  19. THE_ARCH_BIN="frankenphp-linux-aarch64"
  20. ;;
  21. x86_64)
  22. THE_ARCH_BIN="frankenphp-linux-x86_64"
  23. ;;
  24. *)
  25. THE_ARCH_BIN=""
  26. ;;
  27. esac
  28. ;;
  29. Darwin*)
  30. case ${ARCH} in
  31. arm64)
  32. THE_ARCH_BIN="frankenphp-mac-arm64"
  33. ;;
  34. *)
  35. THE_ARCH_BIN="frankenphp-mac-x86_64"
  36. ;;
  37. esac
  38. ;;
  39. Windows | MINGW64_NT*)
  40. echo "❗ Use WSL to run FrankenPHP on Windows: https://learn.microsoft.com/windows/wsl/"
  41. exit 1
  42. ;;
  43. *)
  44. THE_ARCH_BIN=""
  45. ;;
  46. esac
  47. if [ -z "${THE_ARCH_BIN}" ]; then
  48. echo "❗ FrankenPHP is not supported on ${OS} and ${ARCH}"
  49. exit 1
  50. fi
  51. SUDO=""
  52. echo "📦 Downloading ${bold}FrankenPHP${normal} for ${OS} (${ARCH}):"
  53. # check if $DEST is writable and suppress an error message
  54. touch "${DEST}" 2>/dev/null
  55. # we need sudo powers to write to DEST
  56. if [ $? -eq 1 ]; then
  57. echo "❗ You do not have permission to write to ${italic}${DEST}${normal}, enter your password to grant sudo powers"
  58. SUDO="sudo"
  59. fi
  60. if type "curl" >/dev/null 2>&1; then
  61. curl -L --progress-bar "https://github.com/dunglas/frankenphp/releases/latest/download/${THE_ARCH_BIN}" -o "${DEST}"
  62. elif type "wget" >/dev/null 2>&1; then
  63. ${SUDO} wget "https://github.com/dunglas/frankenphp/releases/latest/download/${THE_ARCH_BIN}" -O "${DEST}"
  64. else
  65. echo "❗ Please install ${italic}curl${normal} or ${italic}wget${normal} to download FrankenPHP"
  66. exit 1
  67. fi
  68. ${SUDO} chmod +x "${DEST}"
  69. echo
  70. echo "🥳 FrankenPHP downloaded successfully to ${italic}${DEST}${normal}"
  71. echo "🔧 Move the binary to ${italic}/usr/local/bin/${normal} or another directory in your ${italic}PATH${normal} to use it globally:"
  72. echo " ${bold}sudo mv ${DEST} /usr/local/bin/${normal}"
  73. echo
  74. echo "⭐ If you like FrankenPHP, please give it a star on GitHub: ${italic}https://github.com/dunglas/frankenphp${normal}"