del-ss.sh 1.9 KB

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