renew-ws.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/v2ray/config.json")
  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/v2ray/config.json" | 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/v2ray/config.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  24. exp=$(grep -E "^### " "/etc/v2ray/config.json" | 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/v2ray/config.json
  32. sed -i "s/### $user $exp/### $user $exp4/g" /etc/v2ray/none.json
  33. service cron restart
  34. clear
  35. echo ""
  36. echo " VMESS Account Was Successfully Renewed"
  37. echo " =========================="
  38. echo " Client Name : $user"
  39. echo " Expired On : $exp4"
  40. echo " =========================="