renew-vless.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 "^### " "/etc/v2ray/vless.json")
  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 "^### " "/etc/v2ray/vless.json" | 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 "^### " "/etc/v2ray/vless.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  30. exp=$(grep -E "^### " "/etc/v2ray/vless.json" | 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. sed -i "s/### $user $exp/### $user $exp4/g" /etc/v2ray/vless.json
  38. sed -i "s/### $user $exp/### $user $exp4/g" /etc/v2ray/vnone.json
  39. service cron restart
  40. clear
  41. echo ""
  42. echo " ======================================"
  43. echo " VLESS Account Was Successfully Renewed"
  44. echo " ======================================"
  45. echo " Client Name : $user"
  46. echo " Expired On : $exp4"
  47. echo " ======================================"
  48. echo ""