del-ws.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/config.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/config.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/config.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  29. exp=$(grep -E "^### " "/etc/v2ray/config.json" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
  30. sed -i "/^### $user $exp/,/^},{/d" /etc/v2ray/config.json
  31. sed -i "/^### $user $exp/,/^},{/d" /etc/v2ray/none.json
  32. rm -f /etc/v2ray/$user-tls.json /etc/v2ray/$user-none.json
  33. systemctl restart v2ray
  34. systemctl restart v2ray@none
  35. clear
  36. echo " =================================="
  37. echo " V2RAY Account Deleted Successfully"
  38. echo " =================================="
  39. echo " Client Name : $user"
  40. echo " Expired On : $exp"
  41. echo " =================================="
  42. echo ""