del-vless.sh 1.4 KB

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