del-sstp.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/var/lib/premium-script/data-user-sstp")
  3. if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
  4. echo ""
  5. echo "You have no existing clients!"
  6. exit 1
  7. fi
  8. echo ""
  9. echo " Select the existing client you want to remove"
  10. echo " Press CTRL+C to return"
  11. echo " ==============================="
  12. echo " No Expired User"
  13. grep -E "^### " "/var/lib/premium-script/data-user-sstp" | cut -d ' ' -f 2-3 | nl -s ') '
  14. until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
  15. if [[ ${CLIENT_NUMBER} == '1' ]]; then
  16. read -rp "Pilih salah satu[1]: " CLIENT_NUMBER
  17. else
  18. read -rp "Pilih salah satu [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
  19. fi
  20. done
  21. Client=$(grep -E "^###" /var/lib/premium-script/data-user-sstp | cut -d ' ' -f 2-3 | sed -n "$CLIENT_NUMBER"p)
  22. user=$(grep -E "^###" /var/lib/premium-script/data-user-sstp | cut -d ' ' -f 2 | sed -n "$CLIENT_NUMBER"p)
  23. exp=$(grep -E "^###" /var/lib/premium-script/data-user-sstp | cut -d ' ' -f 3 | sed -n "$CLIENT_NUMBER"p)
  24. sed -i "/^### $user $exp/d" /var/lib/premium-script/data-user-sstp
  25. sed -i '/^'"$user"'/d' /home/sstp/sstp_account
  26. clear
  27. echo " SSTP Account Has Been Successfully Deleted"
  28. echo " =========================="
  29. echo " Client Name : $user"
  30. echo " Expired On : $exp"
  31. echo " =========================="