setup.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. # Check if running on a supported system
  3. case "$(uname -s)" in
  4. Linux)
  5. if [[ -f "/etc/lsb-release" ]]; then
  6. . /etc/lsb-release
  7. if [[ "$DISTRIB_ID" != "Ubuntu" ]]; then
  8. echo "This script only works on Ubuntu, not $DISTRIB_ID."
  9. exit 1
  10. fi
  11. else
  12. if [[ !"$(cat /etc/*-release | grep '^ID=')" =~ ^(ID=\"ubuntu\")|(ID=\"centos\")|(ID=\"arch\")|(ID=\"debian\")$ ]]; then
  13. echo "Unsupported Linux distribution."
  14. exit 1
  15. fi
  16. fi
  17. ;;
  18. Darwin)
  19. echo "Running on MacOS."
  20. ;;
  21. *)
  22. echo "Unsupported operating system."
  23. exit 1
  24. ;;
  25. esac
  26. # Check if needed dependencies are installed and install if necessary
  27. if ! command -v node >/dev/null || ! command -v git >/dev/null || ! command -v yarn >/dev/null; then
  28. case "$(uname -s)" in
  29. Linux)
  30. if [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=ubuntu" ]]; then
  31. sudo apt-get update
  32. sudo apt-get -y install nodejs git yarn
  33. elif [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=debian" ]]; then
  34. sudo apt-get update
  35. sudo apt-get -y install nodejs git yarn
  36. elif [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=centos" ]]; then
  37. sudo yum -y install epel-release
  38. sudo yum -y install nodejs git yarn
  39. elif [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=arch" ]]; then
  40. sudo pacman -Syu -y
  41. sudo pacman -S -y nodejs git yarn
  42. else
  43. echo "Unsupported Linux distribution"
  44. exit 1
  45. fi
  46. ;;
  47. Darwin)
  48. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  49. brew install node git yarn
  50. ;;
  51. esac
  52. fi
  53. # Clone the repository and install dependencies
  54. git clone https://github.com/Yidadaa/ChatGPT-Next-Web
  55. cd ChatGPT-Next-Web
  56. yarn install
  57. # Prompt user for environment variables
  58. read -p "Enter OPENAI_API_KEY: " OPENAI_API_KEY
  59. read -p "Enter CODE: " CODE
  60. read -p "Enter PORT: " PORT
  61. # Build and run the project using the environment variables
  62. OPENAI_API_KEY=$OPENAI_API_KEY CODE=$CODE PORT=$PORT yarn build
  63. OPENAI_API_KEY=$OPENAI_API_KEY CODE=$CODE PORT=$PORT yarn start