renew-xws.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- ifconfig.me/ip);
  6. echo "Checking VPS"
  7. #EDIT IZIN
  8. clear
  9. NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/xray/vmesstls.json")
  10. if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
  11. clear
  12. echo ""
  13. echo " Renew XRAY Vmess Account"
  14. echo ""
  15. echo "You have no existing clients!"
  16. exit 1
  17. fi
  18. clear
  19. echo ""
  20. echo " Renew XRAY Vmess Account"
  21. echo ""
  22. echo "Select the existing client you want to renew"
  23. echo " Press CTRL+C to return"
  24. echo ""
  25. echo -e "==============================="
  26. grep -E "^### " "/etc/xray/vmesstls.json" | cut -d ' ' -f 2-3 | nl -s ') '
  27. until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
  28. if [[ ${CLIENT_NUMBER} == '1' ]]; then
  29. read -rp "Select one client [1]: " CLIENT_NUMBER
  30. else
  31. read -rp "Select one client [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
  32. fi
  33. done
  34. read -p "Expired (days): " masaaktif
  35. user=$(grep -E "^### " "/etc/xray/vmesstls.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
  36. exp=$(grep -E "^### " "/etc/xray/vmesstls.json" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
  37. now=$(date +%Y-%m-%d)
  38. d1=$(date -d "$exp" +%s)
  39. d2=$(date -d "$now" +%s)
  40. exp2=$(( (d1 - d2) / 86400 ))
  41. exp3=$(($exp2 + $masaaktif))
  42. exp4=`date -d "$exp3 days" +"%Y-%m-%d"`
  43. sed -i "s/### $user $exp/### $user $exp4/g" /etc/xray/vmesstls.json
  44. sed -i "s/### $user $exp/### $user $exp4/g" /etc/xray/vmessnone.json
  45. sed -i "s/### $user $exp/### $user $exp4/g" /etc/xray/mkcp.json
  46. service cron restart
  47. clear
  48. echo ""
  49. echo " XRAY VMESS Account Was Successfully Renewed"
  50. echo " =========================="
  51. echo " Client Name : $user"
  52. echo " Expired On : $exp4"
  53. echo " =========================="