install-release.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. echo "Please make sure unzip and daemon are installed before running this script."
  3. VER="v1.1.3"
  4. ARCH=$(uname -m)
  5. VDIS="64"
  6. if [ "$ARCH" == "i686" ] || [ "$ARCH" == "i386" ]; then
  7. VDIS="32"
  8. elif [ "$ARCH" == *"armv7"* ]; then
  9. VDIS="arm"
  10. elif [ "$ARCH" == *"armv8"* ]; then
  11. VDIS="arm64"
  12. fi
  13. DOWNLOAD_LINK="https://github.com/v2ray/v2ray-core/releases/download/${VER}/v2ray-linux-${VDIS}.zip"
  14. rm -rf /tmp/v2ray
  15. mkdir -p /tmp/v2ray
  16. curl -L -o "/tmp/v2ray/v2ray.zip" ${DOWNLOAD_LINK}
  17. unzip "/tmp/v2ray/v2ray.zip" -d "/tmp/v2ray/"
  18. # Create folder for V2Ray log.
  19. mkdir -p /var/log/v2ray
  20. # Install V2Ray binary to /usr/bin/v2ray
  21. mkdir -p /usr/bin/v2ray
  22. cp "/tmp/v2ray/v2ray-${VER}-linux-${VDIS}/v2ray" "/usr/bin/v2ray/v2ray"
  23. chmod +x "/usr/bin/v2ray/v2ray"
  24. # Install V2Ray server config to /etc/v2ray
  25. mkdir -p /etc/v2ray
  26. if [ ! -f "/etc/v2ray/config.json" ]; then
  27. cp "/tmp/v2ray/v2ray-${VER}-linux-${VDIS}/vpoint_vmess_freedom.json" "/etc/v2ray/config.json"
  28. let PORT=$RANDOM+10000
  29. sed -i "s/37192/${PORT}/g" "/etc/v2ray/config.json"
  30. UUID=$(cat /proc/sys/kernel/random/uuid)
  31. sed -i "s/3b129dec-72a3-4d28-aeee-028a0fe86e22/${UUID}/g" "/etc/v2ray/config.json"
  32. echo "PORT:${PORT}"
  33. echo "UUID:${UUID}"
  34. fi
  35. # Configure SysV if necessary.
  36. if [ -d "/etc/init.d" ]; then
  37. if [ ! -f "/etc/init.d/v2ray" ]; then
  38. cp "/tmp/v2ray/v2ray-${VER}-linux-${VDIS}/systemv/v2ray" "/etc/init.d/v2ray"
  39. chmod +x "/etc/init.d/v2ray"
  40. update-rc.d v2ray defaults
  41. fi
  42. fi