del-xws.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. echo "Checking VPS"
  8. #EDIT IZIN
  9. clear
  10. NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/xray/vmesstls.json")
  11. if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
  12. echo ""
  13. echo "Name : Delete XRRAY Vmess Account"
  14. echo ""
  15. echo "You have no existing clients!"
  16. exit 1
  17. fi
  18. clear
  19. echo ""
  20. echo "Name : Delete XRAY Vmess Account"
  21. echo ""
  22. echo " Select the existing client you want to remove"
  23. echo " Press CTRL+C to return"
  24. echo ""
  25. echo " ==============================="
  26. echo " No Expired User"
  27. grep -E "^### " "/etc/xray/vmesstls.json" | cut -d ' ' -f 2-3 | nl -s ') '
  28. until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
  29. if [[ ${CLIENT_NUMBER} == '1' ]]; then
  30. read -rp "Select one client [1]: " CLIENT_NUMBER
  31. else
  32. read -rp "Select one client [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
  33. fi
  34. done
  35. user=$(grep -E "^### " "/etc/xray/vmesstls.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  36. exp=$(grep -E "^### " "/etc/xray/vmesstls.json" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
  37. sed -i "/^### $user $exp/,/^},{/d" /etc/xray/vmesstls.json
  38. sed -i "/^### $user $exp/,/^},{/d" /etc/xray/vmessnone.json
  39. rm -f /etc/xray/$user-tls.json /etc/xray/$user-none.json
  40. systemctl restart xray@vmesstls
  41. systemctl restart xray@vmessnone
  42. clear
  43. echo " XRAY Vmess Account Deleted Successfully"
  44. echo " =========================="
  45. echo " Client Name : $user"
  46. echo " Expired On : $exp"
  47. echo " =========================="