renew-ss.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 renew"
  12. echo " Press CTRL+C to return"
  13. echo -e "==============================="
  14. grep -E "^### " "/etc/shadowsocks-libev/akun.conf" | cut -d ' ' -f 2-3 | nl -s ') '
  15. until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
  16. if [[ ${CLIENT_NUMBER} == '1' ]]; then
  17. read -rp "Select one client [1]: " CLIENT_NUMBER
  18. else
  19. read -rp "Select one client [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
  20. fi
  21. done
  22. read -p "Expired (days): " masaaktif
  23. user=$(grep -E "^### " "/etc/shadowsocks-libev/akun.conf" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  24. exp=$(grep -E "^### " "/etc/shadowsocks-libev/akun.conf" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
  25. now=$(date +%Y-%m-%d)
  26. d1=$(date -d "$exp" +%s)
  27. d2=$(date -d "$now" +%s)
  28. exp2=$(( (d1 - d2) / 86400 ))
  29. exp3=$(($exp2 + $masaaktif))
  30. exp4=`date -d "$exp3 days" +"%Y-%m-%d"`
  31. sed -i "s/### $user $exp/### $user $exp4/g" /etc/shadowsocks-libev/akun.conf
  32. clear
  33. echo ""
  34. echo " SS OBFS Account Has Been Successfully Renewed"
  35. echo " =========================="
  36. echo " Client Name : $user"
  37. echo " Expired On : $exp4"
  38. echo " =========================="