del-vless.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/v2ray/vless.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/vless.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/vless.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  23. exp=$(grep -E "^### " "/etc/v2ray/vless.json" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
  24. sed -i "/^### $user $exp/,/^},{/d" /etc/v2ray/vless.json
  25. sed -i "/^### $user $exp/,/^},{/d" /etc/v2ray/vnone.json
  26. systemctl restart v2ray@vless
  27. systemctl restart v2ray@none
  28. clear
  29. echo " Vless Account Deleted Successfully"
  30. echo " =========================="
  31. echo " Client Name : $user"
  32. echo " Expired On : $exp"
  33. echo " =========================="