del-ssr.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 "^### " "/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 " =========================================="
  42. echo " Shadowsocks-R Account Deleted Successfully"
  43. echo " =========================================="
  44. echo " Client Name : $user"
  45. echo " Expired On : $exp"
  46. echo " =========================================="
  47. echo ""