del-ss.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/shadowsocks-libev/akun.conf")
  3. if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
  4. clear
  5. echo ""
  6. echo "You have no existing clients!"
  7. exit 1
  8. fi
  9. clear
  10. echo ""
  11. echo " Select the existing client you want to remove"
  12. echo " Press CTRL+C to return"
  13. echo " ==============================="
  14. echo " No Expired User"
  15. grep -E "^### " "/etc/shadowsocks-libev/akun.conf" | cut -d ' ' -f 2-3 | nl -s ') '
  16. until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
  17. if [[ ${CLIENT_NUMBER} == '1' ]]; then
  18. read -rp "Pilih salah satu[1]: " CLIENT_NUMBER
  19. else
  20. read -rp "Pilih salah satu [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
  21. fi
  22. done
  23. # match the selected number to a client name
  24. CLIENT_NAME=$(grep -E "^### " "/etc/shadowsocks-libev/akun.conf" | cut -d ' ' -f 2-3 | sed -n "${CLIENT_NUMBER}"p)
  25. user=$(grep -E "^### " "/etc/shadowsocks-libev/akun.conf" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  26. exp=$(grep -E "^### " "/etc/shadowsocks-libev/akun.conf" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
  27. # remove [Peer] block matching $CLIENT_NAME
  28. sed -i "/^### $user $exp/,/^port_http/d" "/etc/shadowsocks-libev/akun.conf"
  29. # remove generated client file
  30. service cron restart
  31. systemctl disable shadowsocks-libev-server@$user-tls.service
  32. systemctl disable shadowsocks-libev-server@$user-http.service
  33. systemctl stop shadowsocks-libev-server@$user-tls.service
  34. systemctl stop shadowsocks-libev-server@$user-http.service
  35. rm -f "/etc/shadowsocks-libev/$user-tls.json"
  36. rm -f "/etc/shadowsocks-libev/$user-http.json"
  37. clear
  38. echo " SS OBFS Account Deleted Successfully"
  39. echo " =========================="
  40. echo " Client Name : $user"
  41. echo " Expired On : $exp"
  42. echo " =========================="