del-xtrgo.sh 1.4 KB

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