del-xray.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- ifconfig.me/ip);
  6. echo "Checking VPS"
  7. #EDIT IZIN
  8. clear
  9. NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/xray/vlessxtls.json")
  10. if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
  11. echo ""
  12. echo " Delete XRAY XTLS Account"
  13. echo ""
  14. echo "You have no existing clients!"
  15. exit 1
  16. fi
  17. clear
  18. echo ""
  19. echo " Delete XRAY XTLS Account"
  20. echo ""
  21. echo " Select the existing client you want to remove"
  22. echo " Press CTRL+C to return"
  23. echo ""
  24. echo " ==============================="
  25. echo " No Expired User"
  26. grep -E "^### " "/etc/xray/vlessxtls.json" | cut -d ' ' -f 2-3 | nl -s ') '
  27. until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
  28. if [[ ${CLIENT_NUMBER} == '1' ]]; then
  29. read -rp "Select one client [1]: " CLIENT_NUMBER
  30. else
  31. read -rp "Select one client [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
  32. fi
  33. done
  34. user=$(grep -E "^### " "/etc/xray/vlessxtls.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  35. exp=$(grep -E "^### " "/etc/xray/vlessxtls.json" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
  36. sed -i "/^### $user $exp/,/^},{/d" /etc/xray/vlessxtls.json
  37. systemctl restart xray@vlessxtls
  38. clear
  39. echo " XRAY XTLS Account Deleted Successfully"
  40. echo " =========================="
  41. echo " Client Name : $user"
  42. echo " Expired On : $exp"
  43. echo " =========================="