Skip to content

Commit 2f0385e

Browse files
authored
Improve formatting and comments in xray-renew script
1 parent 5e63e8d commit 2f0385e

1 file changed

Lines changed: 26 additions & 44 deletions

File tree

xray/xray-renew.sh

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ uuid=$(echo "$line" | awk '{print $4}')
3333
oldexp=$(echo "$line" | awk '{print $5}')
3434

3535
echo ""
36-
echo "User : $user"
37-
echo "Proto : $proto"
38-
echo "UUID : $uuid"
39-
echo "Expire lama : $oldexp"
36+
echo "User : $user"
37+
echo "Proto : $proto"
38+
echo "UUID : $uuid"
39+
echo "Expire lama: $oldexp"
4040
echo ""
4141

4242
echo -n "Perpanjang berapa hari dari hari ini? : "
@@ -55,66 +55,48 @@ newexp=$(date -d "$days days" +"%Y-%m-%d") || {
5555
echo "Expire baru: $newexp"
5656
echo ""
5757

58-
# Sisipkan ke config.json sesuai proto
58+
# ===============================
59+
# SISIPKAN KE CONFIG SESUAI FORMAT MU
60+
# ===============================
5961
case "$proto" in
6062
vmess)
6163
# VMESS WS (marker: #vmess)
62-
sed -i '/#vmess$/i\### '"$user $newexp"'\
63-
{\
64-
"id": "'"$uuid"'",\
65-
"alterId": 0\
66-
},' "$CONFIG"
64+
sed -i '/#vmess$/a\### '"$user $newexp"'\
65+
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' "$CONFIG"
6766

6867
# VMESS gRPC (marker: #vmessgrpc)
69-
sed -i '/#vmessgrpc$/i\### '"$user $newexp"'\
70-
{\
71-
"id": "'"$uuid"'",\
72-
"alterId": 0\
73-
},' "$CONFIG"
68+
sed -i '/#vmessgrpc$/a\### '"$user $newexp"'\
69+
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' "$CONFIG"
7470
;;
7571

7672
vless)
7773
# VLESS WS (marker: #vless)
78-
sed -i '/#vless$/i\#& '"$user $newexp"'\
79-
{\
80-
"id": "'"$uuid"'"\
81-
},' "$CONFIG"
74+
sed -i '/#vless$/a\#& '"$user $newexp"'\
75+
},{"id": "'""$uuid""'","email": "'""$user""'"' "$CONFIG"
8276

8377
# VLESS gRPC (marker: #vlessgrpc)
84-
sed -i '/#vlessgrpc$/i\#& '"$user $newexp"'\
85-
{\
86-
"id": "'"$uuid"'"\
87-
},' "$CONFIG"
78+
sed -i '/#vlessgrpc$/a\#& '"$user $newexp"'\
79+
},{"id": "'""$uuid""'","email": "'""$user""'"' "$CONFIG"
8880
;;
8981

9082
trojan)
9183
# TROJAN WS (marker: #trojanws)
92-
sed -i '/#trojanws$/i\#! '"$user $newexp"'\
93-
{\
94-
"password": "'"$uuid"'"\
95-
},' "$CONFIG"
84+
sed -i '/#trojanws$/a\#! '"$user $newexp"'\
85+
},{"password": "'""$uuid""'","email": "'""$user""'"' "$CONFIG"
9686

9787
# TROJAN gRPC (marker: #trojangrpc)
98-
sed -i '/#trojangrpc$/i\#! '"$user $newexp"'\
99-
{\
100-
"password": "'"$uuid"'"\
101-
},' "$CONFIG"
88+
sed -i '/#trojangrpc$/a\#! '"$user $newexp"'\
89+
},{"password": "'""$uuid""'","email": "'""$user""'"' "$CONFIG"
10290
;;
10391

10492
ss)
105-
# Shadowsocks WS (marker: #ssws)
106-
sed -i '/#ssws$/i\### '"$user $newexp"'\
107-
{\
108-
"method": "aes-128-gcm",\
109-
"password": "'"$uuid"'"\
110-
},' "$CONFIG"
111-
112-
# Shadowsocks gRPC (marker: #ssgrpc)
113-
sed -i '/#ssgrpc$/i\### '"$user $newexp"'\
114-
{\
115-
"method": "aes-128-gcm",\
116-
"password": "'"$uuid"'"\
117-
},' "$CONFIG"
93+
# SHADOWSOCKS WS (marker: #ssws)
94+
sed -i '/#ssws$/a\### '"$user $newexp"'\
95+
},{"method": "aes-128-gcm","password": "'""$uuid""'","email": "'""$user""'"' "$CONFIG"
96+
97+
# SHADOWSOCKS gRPC (marker: #ssgrpc)
98+
sed -i '/#ssgrpc$/a\### '"$user $newexp"'\
99+
},{"method": "aes-128-gcm","password": "'""$uuid""'","email": "'""$user""'"' "$CONFIG"
118100
;;
119101

120102
*)

0 commit comments

Comments
 (0)