del-sstp.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 "^### " "/var/lib/premium-script/data-user-sstp")
  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 " ==============================="
  18. echo " No Expired User"
  19. grep -E "^### " "/var/lib/premium-script/data-user-sstp" | 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 "Pilih salah satu[1]: " CLIENT_NUMBER
  23. else
  24. read -rp "Pilih salah satu [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
  25. fi
  26. done
  27. Client=$(grep -E "^###" /var/lib/premium-script/data-user-sstp | cut -d ' ' -f 2-3 | sed -n "$CLIENT_NUMBER"p)
  28. user=$(grep -E "^###" /var/lib/premium-script/data-user-sstp | cut -d ' ' -f 2 | sed -n "$CLIENT_NUMBER"p)
  29. exp=$(grep -E "^###" /var/lib/premium-script/data-user-sstp | cut -d ' ' -f 3 | sed -n "$CLIENT_NUMBER"p)
  30. sed -i "/^### $user $exp/d" /var/lib/premium-script/data-user-sstp
  31. sed -i '/^'"$user"'/d' /home/sstp/sstp_account
  32. clear
  33. echo " SSTP Account Has Been Successfully Deleted"
  34. echo " =========================="
  35. echo " Client Name : $user"
  36. echo " Expired On : $exp"
  37. echo " =========================="