install-release.sh 2.0 KB

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