port-xray.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. direct="$(cat ~/log-install.txt | grep -w "XRAY VLESS XTLS" | cut -d: -f2|sed 's/ //g')"
  3. direct="$(cat ~/log-install.txt | grep -w "XRAY VLESS SPLICE" | cut -d: -f2|sed 's/ //g')"
  4. direct="$(cat ~/log-install.txt | grep -w "XRAY VLESS WS XTLS" | cut -d: -f2|sed 's/ //g')"
  5. echo -e " Change Port $direct"
  6. read -p "New Port XRAY XTLS,XRAY VLESS WS XTLS and XRAY VLESS SPLICE: " direct1
  7. if [ -z $direct1 ]; then
  8. echo "Please Input Port"
  9. exit 0
  10. fi
  11. cek=$(netstat -nutlp | grep -w $direct1)
  12. if [[ -z $cek ]]; then
  13. sed -i "s/$direct/$direct1/g" /etc/xray/vlessxtls.json
  14. sed -i "s/$direct/$direct1/g" /etc/xray/vlesslice.json
  15. sed -i "s/$direct/$direct1/g" /etc/xray/vlessws.json
  16. sed -i "s/ - XRAY VLESS XTLS : $direct/ - XRAY VLESS XTLS : $direct1/g" /root/log-install.txt
  17. sed -i "s/ - XRAY VLESS SPLICE : $direct/ - XRAY VLESS SPLICE : $direct1/g" /root/log-install.txt
  18. sed -i "s/ - XRAY VLESS WS XTLS : $direct/ - XRAY VLESS WS XTLS : $direct1/g" /root/log-install.txt
  19. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $direct -j ACCEPT
  20. iptables -D INPUT -m state --state NEW -m udp -p udp --dport $direct -j ACCEPT
  21. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $direct1 -j ACCEPT
  22. iptables -I INPUT -m state --state NEW -m udp -p udp --dport $direct1 -j ACCEPT
  23. iptables-save > /etc/iptables.up.rules
  24. iptables-restore -t < /etc/iptables.up.rules
  25. netfilter-persistent save > /dev/null
  26. netfilter-persistent reload > /dev/null
  27. systemctl restart xray > /dev/null
  28. systemctl stop xray@vlessxtls > /dev/null
  29. systemctl enable xray@vlessxtls > /dev/null
  30. systemctl start xray@vlessxtls > /dev/null
  31. systemctl stop xray@vlesslice > /dev/null
  32. systemctl enable xray@vlesslice > /dev/null
  33. systemctl start xray@vlesslice > /dev/null
  34. systemctl stop xray@vlessws > /dev/null
  35. systemctl enable xray@vlessws > /dev/null
  36. systemctl start xray@vlessws > /dev/null
  37. echo -e "\e[032;1mPort $direct1 modified successfully\e[0m"
  38. else
  39. echo "Port $direct1 is used"
  40. fi