renew-xtrgo.sh 1.5 KB

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