install-release.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. YUM_CMD=$(command -v yum)
  3. APT_CMD=$(command -v apt-get)
  4. if [ -n "${YUM_CMD}" ]; then
  5. echo "Installing unzip and daemon via yum."
  6. ${YUM_CMD} -q makecache
  7. ${YUM_CMD} -y -q install unzip daemon
  8. elif [ -n "${APT_CMD}" ]; then
  9. echo "Installing unzip and daemon via apt-get."
  10. ${APT_CMD} -qq update
  11. ${APT_CMD} -y -qq install unzip daemon
  12. else
  13. echo "Please make sure unzip and daemon are installed."
  14. fi
  15. VER="v1.3"
  16. ARCH=$(uname -m)
  17. VDIS="64"
  18. if [[ "$ARCH" == "i686" ]] || [[ "$ARCH" == "i386" ]]; then
  19. VDIS="32"
  20. elif [[ "$ARCH" == *"armv7"* ]]; then
  21. VDIS="arm"
  22. elif [[ "$ARCH" == *"armv8"* ]]; then
  23. VDIS="arm64"
  24. fi
  25. DOWNLOAD_LINK="https://github.com/v2ray/v2ray-core/releases/download/${VER}/v2ray-linux-${VDIS}.zip"
  26. rm -rf /tmp/v2ray
  27. mkdir -p /tmp/v2ray
  28. curl -L -o "/tmp/v2ray/v2ray.zip" ${DOWNLOAD_LINK}
  29. unzip "/tmp/v2ray/v2ray.zip" -d "/tmp/v2ray/"
  30. # Create folder for V2Ray log.
  31. mkdir -p /var/log/v2ray
  32. # Install V2Ray binary to /usr/bin/v2ray
  33. mkdir -p /usr/bin/v2ray
  34. cp "/tmp/v2ray/v2ray-${VER}-linux-${VDIS}/v2ray" "/usr/bin/v2ray/v2ray"
  35. chmod +x "/usr/bin/v2ray/v2ray"
  36. # Install V2Ray server config to /etc/v2ray
  37. mkdir -p /etc/v2ray
  38. if [ ! -f "/etc/v2ray/config.json" ]; then
  39. cp "/tmp/v2ray/v2ray-${VER}-linux-${VDIS}/vpoint_vmess_freedom.json" "/etc/v2ray/config.json"
  40. let PORT=$RANDOM+10000
  41. sed -i "s/37192/${PORT}/g" "/etc/v2ray/config.json"
  42. UUID=$(cat /proc/sys/kernel/random/uuid)
  43. sed -i "s/3b129dec-72a3-4d28-aeee-028a0fe86e22/${UUID}/g" "/etc/v2ray/config.json"
  44. echo "PORT:${PORT}"
  45. echo "UUID:${UUID}"
  46. fi
  47. #if [ -d "/lib/systemd/system" ]; then
  48. # if [ ! -f "/lib/systemd/system/v2ray.service" ]; then
  49. # cp "/tmp/v2ray/v2ray-${VER}-linux-${VDIS}/systemd/v2ray.service" "/lib/systemd/system/"
  50. # systemctl enable v2ray
  51. # fi
  52. #el
  53. if [ -d "/etc/init.d" ]; then # Configure SysV if necessary.
  54. if [ ! -f "/etc/init.d/v2ray" ]; then
  55. cp "/tmp/v2ray/v2ray-${VER}-linux-${VDIS}/systemv/v2ray" "/etc/init.d/v2ray"
  56. chmod +x "/etc/init.d/v2ray"
  57. update-rc.d v2ray defaults
  58. fi
  59. fi