add-tr.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. uuid=$(cat /etc/trojan/uuid.txt)
  7. source /var/lib/premium-script/ipvps.conf
  8. if [[ "$IP" = "" ]]; then
  9. domain=$(cat /etc/v2ray/domain)
  10. else
  11. domain=$IP
  12. fi
  13. tr="$(cat ~/log-install.txt | grep -i Trojan | cut -d: -f2|sed 's/ //g')"
  14. until [[ $user =~ ^[a-zA-Z0-9_]+$ && ${user_EXISTS} == '0' ]]; do
  15. read -rp "Password: " -e user
  16. user_EXISTS=$(grep -w $user /etc/trojan/akun.conf | wc -l)
  17. if [[ ${user_EXISTS} == '1' ]]; then
  18. echo ""
  19. echo "A client with the specified name was already created, please choose another name."
  20. exit 1
  21. fi
  22. done
  23. read -p "Expired (days): " masaaktif
  24. sed -i '/"'""$uuid""'"$/a\,"'""$user""'"' /etc/trojan/config.json
  25. exp=`date -d "$masaaktif days" +"%Y-%m-%d"`
  26. echo -e "### $user $exp" >> /etc/trojan/akun.conf
  27. systemctl restart trojan
  28. trojanlink="trojan://${user}@${domain}:${tr}"
  29. clear
  30. echo -e ""
  31. echo -e "=============-Trojan-============"
  32. echo -e "Remarks : ${user}"
  33. echo -e "Host/IP : ${domain}"
  34. echo -e "port : ${tr}"
  35. echo -e "Key : ${user}"
  36. echo -e "link : ${trojanlink}"
  37. echo -e "================================="
  38. echo -e "Expired On : $exp"