add-ws.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. source /var/lib/premium-script/ipvps.conf
  9. if [[ "$IP" = "" ]]; then
  10. domain=$(cat /etc/v2ray/domain)
  11. else
  12. domain=$IP
  13. fi
  14. tls="$(cat ~/log-install.txt | grep -w "Vmess TLS" | cut -d: -f2|sed 's/ //g')"
  15. none="$(cat ~/log-install.txt | grep -w "Vmess None TLS" | cut -d: -f2|sed 's/ //g')"
  16. until [[ $user =~ ^[a-zA-Z0-9_]+$ && ${CLIENT_EXISTS} == '0' ]]; do
  17. read -rp "User: " -e user
  18. CLIENT_EXISTS=$(grep -w $user /etc/v2ray/config.json | wc -l)
  19. if [[ ${CLIENT_EXISTS} == '1' ]]; then
  20. echo ""
  21. echo "A Client Username Was Already Created, Please Enter New Username"
  22. exit 1
  23. fi
  24. done
  25. uuid=$(cat /proc/sys/kernel/random/uuid)
  26. read -p "Expired (days): " masaaktif
  27. exp=`date -d "$masaaktif days" +"%Y-%m-%d"`
  28. sed -i '/#tls$/a\### '"$user $exp"'\
  29. },{"id": "'""$uuid""'","alterId": '"2"',"email": "'""$user""'"' /etc/v2ray/config.json
  30. sed -i '/#none$/a\### '"$user $exp"'\
  31. },{"id": "'""$uuid""'","alterId": '"2"',"email": "'""$user""'"' /etc/v2ray/none.json
  32. cat>/etc/v2ray/$user-tls.json<<EOF
  33. {
  34. "v": "2",
  35. "ps": "${user}",
  36. "add": "${domain}",
  37. "port": "${tls}",
  38. "id": "${uuid}",
  39. "aid": "2",
  40. "net": "ws",
  41. "path": "/v2ray",
  42. "type": "none",
  43. "host": "",
  44. "tls": "tls"
  45. }
  46. EOF
  47. cat>/etc/v2ray/$user-none.json<<EOF
  48. {
  49. "v": "2",
  50. "ps": "${user}",
  51. "add": "${domain}",
  52. "port": "${none}",
  53. "id": "${uuid}",
  54. "aid": "2",
  55. "net": "ws",
  56. "path": "/v2ray",
  57. "type": "none",
  58. "host": "",
  59. "tls": "none"
  60. }
  61. EOF
  62. vmess_base641=$( base64 -w 0 <<< $vmess_json1)
  63. vmess_base642=$( base64 -w 0 <<< $vmess_json2)
  64. vmesslink1="vmess://$(base64 -w 0 /etc/v2ray/$user-tls.json)"
  65. vmesslink2="vmess://$(base64 -w 0 /etc/v2ray/$user-none.json)"
  66. systemctl restart v2ray
  67. systemctl restart v2ray@none
  68. service cron restart
  69. clear
  70. echo -e ""
  71. echo -e "==============================="
  72. echo -e "V2RAY/VMESS Information Account"
  73. echo -e "==============================="
  74. echo -e "Remarks : ${user}"
  75. echo -e "Domain : ${domain}"
  76. echo -e "Port TLS : ${tls}"
  77. echo -e "Port none TLS : ${none}"
  78. echo -e "Id : ${uuid}"
  79. echo -e "AlterId : 2"
  80. echo -e "Security : auto"
  81. echo -e "Network : ws"
  82. echo -e "Host : bug"
  83. echo -e "Path : /v2ray"
  84. echo -e "==============================="
  85. echo -e "link TLS : ${vmesslink1}"
  86. echo -e ""
  87. echo -e "link none TLS : ${vmesslink2}"
  88. echo -e "==============================="
  89. echo -e "Expired On : $exp"
  90. echo -e "Create By EvoTeamMalaysia"
  91. echo -e ""