del-ws.sh 1.3 KB

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