add-vless.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. source /var/lib/premium-script/ipvps.conf
  3. if [[ "$IP" = "" ]]; then
  4. domain=$(cat /etc/v2ray/domain)
  5. else
  6. domain=$IP
  7. fi
  8. tls="$(cat ~/log-install.txt | grep -w "Vless TLS" | cut -d: -f2|sed 's/ //g')"
  9. none="$(cat ~/log-install.txt | grep -w "Vless None TLS" | cut -d: -f2|sed 's/ //g')"
  10. until [[ $user =~ ^[a-zA-Z0-9_]+$ && ${CLIENT_EXISTS} == '0' ]]; do
  11. read -rp "User: " -e user
  12. CLIENT_EXISTS=$(grep -w $user /etc/v2ray/vless.json | wc -l)
  13. if [[ ${CLIENT_EXISTS} == '1' ]]; then
  14. echo ""
  15. echo "A client with the specified name was already created, please choose another name."
  16. exit 1
  17. fi
  18. done
  19. uuid=$(cat /proc/sys/kernel/random/uuid)
  20. read -p "Expired (days): " masaaktif
  21. exp=`date -d "$masaaktif days" +"%Y-%m-%d"`
  22. sed -i '/#tls$/a\### '"$user $exp"'\
  23. },{"id": "'""$uuid""'","email": "'""$user""'"' /etc/v2ray/vless.json
  24. sed -i '/#none$/a\### '"$user $exp"'\
  25. },{"id": "'""$uuid""'","email": "'""$user""'"' /etc/v2ray/vnone.json
  26. vlesslink1="vless://${uuid}@${domain}:$tls?path=/v2ray&security=tls&encryption=none&type=ws#${user}"
  27. vlesslink2="vless://${uuid}@${domain}:$none?path=/v2ray&encryption=none&type=ws#${user}"
  28. systemctl restart v2ray@vless
  29. systemctl restart v2ray@vnone
  30. clear
  31. echo -e ""
  32. echo -e "==========-V2RAY/VLESS-=========="
  33. echo -e "Remarks : ${user}"
  34. echo -e "Domain : ${domain}"
  35. echo -e "port TLS : $tls"
  36. echo -e "port none TLS : $none"
  37. echo -e "id : ${uuid}"
  38. echo -e "Encryption : none"
  39. echo -e "network : ws"
  40. echo -e "path : /v2ray"
  41. echo -e "================================="
  42. echo -e "link TLS : ${vlesslink1}"
  43. echo -e "================================="
  44. echo -e "link none TLS : ${vlesslink2}"
  45. echo -e "================================="
  46. echo -e "Expired On : $exp"