setup.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\")$ ]]; 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=centos" ]]; then
  34. sudo yum -y install epel-release
  35. sudo yum -y install nodejs git yarn
  36. elif [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=arch" ]]; then
  37. sudo pacman -Syu -y
  38. sudo pacman -S -y nodejs git yarn
  39. else
  40. echo "Unsupported Linux distribution"
  41. exit 1
  42. fi
  43. ;;
  44. Darwin)
  45. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  46. brew install node git yarn
  47. ;;
  48. esac
  49. fi
  50. # Clone the repository and install dependencies
  51. git clone https://github.com/Yidadaa/ChatGPT-Next-Web
  52. cd ChatGPT-Next-Web
  53. yarn install
  54. # Prompt user for environment variables
  55. read -p "Enter OPENAI_API_KEY: " OPENAI_API_KEY
  56. read -p "Enter CODE: " CODE
  57. read -p "Enter PORT: " PORT
  58. # Build and run the project using the environment variables
  59. OPENAI_API_KEY=$OPENAI_API_KEY CODE=$CODE PORT=$PORT yarn build
  60. OPENAI_API_KEY=$OPENAI_API_KEY CODE=$CODE PORT=$PORT yarn start