renew-ssr.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 renew"
  18. echo " Press CTRL+C to return"
  19. echo -e "==============================="
  20. grep -E "^### " "/usr/local/shadowsocksr/akun.conf" | cut -d ' ' -f 2-3 | nl -s ') '
  21. until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
  22. if [[ ${CLIENT_NUMBER} == '1' ]]; then
  23. read -rp "Select one client [1]: " CLIENT_NUMBER
  24. else
  25. read -rp "Select one client [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
  26. fi
  27. done
  28. read -p "Expired (days): " masaaktif
  29. user=$(grep -E "^### " "/usr/local/shadowsocksr/akun.conf" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  30. exp=$(grep -E "^### " "/usr/local/shadowsocksr/akun.conf" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
  31. now=$(date +%Y-%m-%d)
  32. d1=$(date -d "$exp" +%s)
  33. d2=$(date -d "$now" +%s)
  34. exp2=$(( (d1 - d2) / 86400 ))
  35. exp3=$(($exp2 + $masaaktif))
  36. exp4=`date -d "$exp3 days" +"%Y-%m-%d"`
  37. tgl=$(echo "$exp4" | cut -d- -f3)
  38. bln=$(echo "$exp4" | cut -d- -f2)
  39. sed -i "s/### $user $exp/### $user $exp4/g" /usr/local/shadowsocksr/akun.conf
  40. clear
  41. echo ""
  42. echo " Shadowsocks-R Account Has Been Successfully Renewed"
  43. echo " =========================="
  44. echo " Client Name : $user"
  45. echo " Expired On : $exp4"
  46. echo " =========================="