easy-install.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/bash
  2. # Check if Docker is installed
  3. if ! command -v docker &>/dev/null; then
  4. read -p "Docker is not installed. Do you want to install Docker? (Y/n): " INSTALL_DOCKER
  5. if [[ "${INSTALL_DOCKER:-Y}" =~ ^[Yy]$ ]]; then
  6. curl -fsSL https://get.docker.com | sudo bash
  7. if ! command -v docker &>/dev/null; then
  8. echo "Docker installation failed. Exiting."
  9. exit 1
  10. fi
  11. # Install Docker Compose
  12. sudo apt update && sudo apt install -y docker-compose
  13. if ! command -v docker-compose &>/dev/null; then
  14. echo "Docker Compose installation failed. Exiting."
  15. exit 1
  16. fi
  17. else
  18. echo "Exiting setup. Docker installation required."
  19. exit 1
  20. fi
  21. fi
  22. # Clone the Git repository only if it doesn't already exist
  23. REPO_NAME="v2ray-nginx-cloudflare"
  24. REPO_URL="https://github.com/samrand96/v2ray-nginx-cloudflare.git"
  25. # Check if the repository directory exists and is a Git repository
  26. if [ -d "$REPO_NAME/.git" ]; then
  27. echo "Repository '$REPO_NAME' already exists and is a Git repository. Skipping cloning."
  28. else
  29. echo "Cloning repository '$REPO_NAME'..."
  30. if git clone "$REPO_URL"; then
  31. echo "Repository cloned successfully."
  32. else
  33. echo "Failed to clone the repository. Exiting."
  34. exit 1
  35. fi
  36. fi
  37. cd "$REPO_NAME" || { echo "Failed to navigate to the repository directory. Exiting."; exit 1; }
  38. # Generate random UUID
  39. read -p "Do you want to use a custom UUID? (Y/n): " CUSTOM_UUID
  40. if [[ "${CUSTOM_UUID:-Y}" =~ ^[Yy]$ ]]; then
  41. read -p "Enter your custom UUID: " UUID
  42. UUID=${UUID:-$(cat /proc/sys/kernel/random/uuid)}
  43. else
  44. UUID=$(cat /proc/sys/kernel/random/uuid)
  45. fi
  46. # Update the <UPSTREAM-UUID> field in config.json
  47. if ! sed -i "s#<UPSTREAM-UUID>#$UUID#g" ./v2ray/config/config.json; then
  48. echo "Failed to update UUID in config.json. Exiting."
  49. exit 1
  50. fi
  51. # Prompt for domain and email
  52. read -p "Enter your domain: " DOMAIN
  53. read -p "Enter your email: " EMAIL
  54. # Replace placeholders in docker-compose.yml
  55. if ! sed -i "s#YOUR_DOMAIN#$DOMAIN#g" ./docker-compose.yml || ! sed -i "s#YOUR_EMAIL#$EMAIL#g" ./docker-compose.yml; then
  56. echo "Failed to update placeholders in docker-compose.yml. Exiting."
  57. exit 1
  58. fi
  59. # Compose the Docker setup
  60. if ! sudo docker-compose up -d; then
  61. echo "Failed to start Docker containers. Exiting."
  62. exit 1
  63. fi
  64. # Prompt for CDN usage
  65. read -p "Now go and adjust CDN settings. Activate the proxy option in your CDN for the record to enhance delivery capabilities. Press Enter when finished." USE_CDN
  66. if [[ "${USE_CDN:-Y}" =~ ^[Yy]$ ]]; then
  67. chmod +x vmess.py
  68. if ! ./vmess.py; then
  69. echo "Failed to execute vmess.py. Exiting."
  70. exit 1
  71. fi
  72. fi
  73. echo "Setup completed successfully."