del-ssr.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 "^### " "/usr/local/shadowsocksr/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 "^### " "/usr/local/shadowsocksr/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 "Select one client [1]: " CLIENT_NUMBER
  25. else
  26. read -rp "Select one client [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
  27. fi
  28. done
  29. # match the selected number to a client name
  30. CLIENT_NAME=$(grep -E "^### " "/usr/local/shadowsocksr/akun.conf" | cut -d ' ' -f 2-3 | sed -n "${CLIENT_NUMBER}"p)
  31. user=$(grep -E "^### " "/usr/local/shadowsocksr/akun.conf" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  32. exp=$(grep -E "^### " "/usr/local/shadowsocksr/akun.conf" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
  33. # remove [Peer] block matching $CLIENT_NAME
  34. sed -i "/^### $CLIENT_NAME/d" "/usr/local/shadowsocksr/akun.conf"
  35. cd /usr/local/shadowsocksr
  36. match_del=$(python mujson_mgr.py -d -u "${user}"|grep -w "delete user")
  37. cd
  38. service cron restart
  39. /etc/init.d/ssrmu restart
  40. clear
  41. echo " Shadowsocks-R Account Deleted Successfully"
  42. echo " =========================="
  43. echo " Client Name : $user"
  44. echo " Expired On : $exp"
  45. echo " =========================="