-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathadd-ws.sh
91 lines (90 loc) · 2.62 KB
/
add-ws.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
red='\e[1;31m'
green='\e[0;32m'
NC='\e[0m'
MYIP=$(wget -qO- icanhazip.com);
echo "Script By Senovpn"
clear
source /var/lib/premium-script/ipvps.conf
if [[ "$IP" = "" ]]; then
domain=$(cat /etc/v2ray/domain)
else
domain=$IP
fi
tls="$(cat ~/log-install.txt | grep -w "Vmess TLS" | cut -d: -f2|sed 's/ //g')"
none="$(cat ~/log-install.txt | grep -w "Vmess None TLS" | cut -d: -f2|sed 's/ //g')"
until [[ $user =~ ^[a-zA-Z0-9_]+$ && ${CLIENT_EXISTS} == '0' ]]; do
read -rp "User: " -e user
CLIENT_EXISTS=$(grep -w $user /etc/v2ray/config.json | wc -l)
if [[ ${CLIENT_EXISTS} == '1' ]]; then
echo ""
echo "A client with the specified name was already created, please choose another name."
exit 1
fi
done
uuid=$(cat /proc/sys/kernel/random/uuid)
read -p "Expired (days): " masaaktif
exp=`date -d "$masaaktif days" +"%d-%m-%Y"`
created=`date -d "0 days" +"%d-%m-%Y"`
sed -i '/#tls$/a\### '"$user $exp"'\
},{"id": "'""$uuid""'","alterId": '"2"',"email": "'""$user""'"' /etc/v2ray/config.json
sed -i '/#none$/a\### '"$user $exp"'\
},{"id": "'""$uuid""'","alterId": '"2"',"email": "'""$user""'"' /etc/v2ray/none.json
cat>/etc/v2ray/$user-tls.json<<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "${tls}",
"id": "${uuid}",
"aid": "2",
"net": "ws",
"path": "/senovpn",
"type": "none",
"host": "",
"tls": "tls"
}
EOF
cat>/etc/v2ray/$user-none.json<<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "${none}",
"id": "${uuid}",
"aid": "2",
"net": "ws",
"path": "/senovpn",
"type": "none",
"host": "",
"tls": "none"
}
EOF
vmess_base641=$( base64 -w 0 <<< $vmess_json1)
vmess_base642=$( base64 -w 0 <<< $vmess_json2)
vmesslink1="vmess://$(base64 -w 0 /etc/v2ray/$user-tls.json)"
vmesslink2="vmess://$(base64 -w 0 /etc/v2ray/$user-none.json)"
systemctl restart v2ray
systemctl restart v2ray@none
service cron restart
clear
echo -e "==========-V2RAY/VMESS-=========="
echo -e "Remarks : ${user}"
echo -e "Domain : ${domain}"
echo -e "port TLS : ${tls}"
echo -e "port none TLS : ${none}"
echo -e "id : ${uuid}"
echo -e "alterId : 2"
echo -e "Security : auto"
echo -e "network : ws"
echo -e "path : /senovpn"
echo -e "Created : $created"
echo -e "Expired : $exp"
echo -e "================================="
echo -e "link TLS : ${vmesslink1}"
echo -e "================================="
echo -e "link none TLS : ${vmesslink2}"
echo -e "================================="
echo -e ""
echo -e "Script By @senovpn"
echo -e ""