renew-xray.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/xray/vlessxtls.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/xray/vlessxtls.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/xray/vlessxtls.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  24. exp=$(grep -E "^### " "/etc/xray/vlessxtls.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/xray/vlessxtls.json
  32. sed -i "s/### $user $exp/### $user $exp4/g" /etc/xray/vlesslice.json
  33. sed -i "s/### $user $exp/### $user $exp4/g" /etc/xray/vlessws.json
  34. service cron restart
  35. clear
  36. echo ""
  37. echo " ✅DONE RENEW ACCOUNT, TERIMA KASIH YA"
  38. echo " =========================="
  39. echo " Client Name : $user"
  40. echo " Expired On : $exp4"
  41. echo " =========================="