@@ -10,6 +10,15 @@ PLAIN='\033[0m'
10
10
11
11
OS=` hostnamectl | grep -i system | cut -d: -f2`
12
12
13
+ V6_PROXY=" "
14
+ IP=` curl -4 ip.sb`
15
+ if [[ " $? " != " 0" ]]; then
16
+ IP=` curl -6 ip.sb`
17
+ V6_PROXY=" https://cool-firefly-b19e.hijk.workers.dev/"
18
+ fi
19
+
20
+ CONFIG_FILE=" /etc/v2ray/config.json"
21
+
13
22
colorEcho () {
14
23
echo -e " ${1}${@: 2}${PLAIN} "
15
24
}
@@ -102,17 +111,17 @@ preinstall() {
102
111
103
112
installV2ray () {
104
113
colorEcho $BLUE " 安装v2ray..."
105
- bash <( curl -sL https://raw.githubusercontent.com/hijkpw/scripts/master/goV2.sh)
114
+ bash <( curl -sL ${V6_PROXY} https://raw.githubusercontent.com/hijkpw/scripts/master/goV2.sh)
106
115
107
- if [ ! -f /etc/v2ray/config.json ]; then
116
+ if [ ! -f $CONFIG_FILE ]; then
108
117
colorEcho $RED " $OS 安装V2ray失败,请到 https://hijk.art 网站反馈"
109
118
exit 1
110
119
fi
111
120
112
- sed -i -e " s/port\" :.*[0-9]*,/port\" : ${PORT} ,/" /etc/v2ray/config.json
121
+ sed -i -e " s/port\" :.*[0-9]*,/port\" : ${PORT} ,/" $CONFIG_FILE
113
122
alterid=` shuf -i50-80 -n1`
114
- sed -i -e " s/alterId\" :.*[0-9]*/alterId\" : ${alterid} /" /etc/v2ray/config.json
115
- uid=` cat /etc/v2ray/config.json | grep id | cut -d: -f2 | tr -d \" ,' ' `
123
+ sed -i -e " s/alterId\" :.*[0-9]*/alterId\" : ${alterid} /" $CONFIG_FILE
124
+ uid=` grep id $CONFIG_FILE | cut -d: -f2 | tr -d \" ,' ' `
116
125
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
117
126
ntpdate -u time.nist.gov
118
127
@@ -173,34 +182,36 @@ installBBR() {
173
182
fi
174
183
175
184
colorEcho $BLUE " 安装BBR模块..."
176
- rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
177
- rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
178
- yum --enablerepo=elrepo-kernel install kernel-ml -y
179
- grub2-set-default 0
180
- echo " tcp_bbr" >> /etc/modules-load.d/modules.conf
181
- echo " 3" > /proc/sys/net/ipv4/tcp_fastopen
182
- INSTALL_BBR=true
185
+ if [[ " $V6_PROXY " = " " ]]; then
186
+ rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
187
+ rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
188
+ yum --enablerepo=elrepo-kernel install kernel-ml -y
189
+ grub2-set-default 0
190
+ echo " tcp_bbr" >> /etc/modules-load.d/modules.conf
191
+ echo " 3" > /proc/sys/net/ipv4/tcp_fastopen
192
+ INSTALL_BBR=true
193
+ fi
183
194
}
184
195
185
196
info () {
186
- if [ ! -f /etc/v2ray/config.json ]; then
197
+ if [ ! -f $CONFIG_FILE ]; then
187
198
echo -e " ${RED} 未安装v2ray!${PLAIN} "
188
199
exit 1
189
200
fi
190
- ip= ` curl -sL -4 ip.sb `
191
- port=` cat /etc/v2ray/config.json | grep port | cut -d: -f2 | tr -d \" ,' ' `
201
+
202
+ port=` grep port $CONFIG_FILE | cut -d: -f2 | tr -d \" ,' ' `
192
203
res=` netstat -nltp | grep ${port} | grep v2ray`
193
204
[ -z " $res " ] && status=" ${RED} 已停止${PLAIN} " || status=" ${GREEN} 正在运行${PLAIN} "
194
- uid=` cat /etc/v2ray/config.json | grep id | cut -d: -f2 | tr -d \" ,' ' `
195
- alterid=` cat /etc/v2ray/config.json | grep alterId | cut -d: -f2 | tr -d \" ,' ' `
196
- res=` cat /etc/v2ray/config.json | grep network`
197
- [ -z " $res " ] && network=" tcp" || network=` cat /etc/v2ray/config.json | grep network | cut -d: -f2 | tr -d \" ,' ' `
205
+ uid=` grep id $CONFIG_FILE | cut -d: -f2 | tr -d \" ,' ' `
206
+ alterid=` grep alterId $CONFIG_FILE | cut -d: -f2 | tr -d \" ,' ' `
207
+ res=` grep network $CONFIG_FILE `
208
+ [ -z " $res " ] && network=" tcp" || network=` grep network $CONFIG_FILE | cut -d: -f2 | tr -d \" ,' ' `
198
209
security=" auto"
199
210
200
211
raw=" {
201
212
\" v\" :\" 2\" ,
202
213
\" ps\" :\"\" ,
203
- \" add\" :\" $ip \" ,
214
+ \" add\" :\" $IP \" ,
204
215
\" port\" :\" ${port} \" ,
205
216
\" id\" :\" ${uid} \" ,
206
217
\" aid\" :\" $alterid \" ,
@@ -215,10 +226,10 @@ info() {
215
226
216
227
echo ============================================
217
228
echo -e " ${BLUE} v2ray运行状态:${PLAIN} ${status} "
218
- echo -e " ${BLUE} v2ray配置文件:${PLAIN} ${RED} /etc/v2ray/config.json ${PLAIN} "
229
+ echo -e " ${BLUE} v2ray配置文件:${PLAIN} ${RED} $CONFIG_FILE ${PLAIN} "
219
230
echo " "
220
231
echo -e " ${RED} v2ray配置信息:${PLAIN} "
221
- echo -e " ${BLUE} IP(address):${PLAIN} ${RED}${ip }${PLAIN} "
232
+ echo -e " ${BLUE} IP(address):${PLAIN} ${RED}${IP }${PLAIN} "
222
233
echo -e " ${BLUE} 端口(port):${PLAIN} ${RED}${port}${PLAIN} "
223
234
echo -e " ${BLUE} id(uuid):${PLAIN} ${RED}${uid}${PLAIN} "
224
235
echo -e " ${BLUE} 额外id(alterid):${PLAIN} ${RED}${alterid}${PLAIN} "
0 commit comments