Skip to content

Commit c029838

Browse files
committed
feat(*.sh): add ipv6 only support
1 parent 322efe6 commit c029838

15 files changed

+492
-231
lines changed

centos_install_ss.sh

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ PLAIN='\033[0m'
1212
BASE=`pwd`
1313
OS=`hostnamectl | grep -i system | cut -d: -f2`
1414

15+
V6_PROXY=""
16+
IP=`curl -4 ip.sb`
17+
if [[ "$?" != "0" ]]; then
18+
IP=`curl -6 ip.sb`
19+
V6_PROXY="https://cool-firefly-b19e.hijk.workers.dev/"
20+
fi
21+
22+
CONFIG_FILE="/etc/shadowsocks-libev/config.json"
1523

1624
colorEcho() {
1725
echo -e "${1}${@:2}${PLAIN}"
@@ -194,7 +202,7 @@ normalizeVersion() {
194202

195203
installNewVer() {
196204
new_ver=$1
197-
if ! wget "https://github.com/shadowsocks/shadowsocks-libev/releases/download/v${new_ver}/shadowsocks-libev-${new_ver}.tar.gz" -O shadowsocks-libev.tar.gz; then
205+
if ! wget "${V6_PROXY}https://github.com/shadowsocks/shadowsocks-libev/releases/download/v${new_ver}/shadowsocks-libev-${new_ver}.tar.gz" -O shadowsocks-libev.tar.gz; then
198206
colorEcho $RED " 下载安装文件失败!"
199207
exit 1
200208
fi
@@ -214,7 +222,7 @@ installNewVer() {
214222
installSS() {
215223
colorEcho $BLUE " 安装SS..."
216224

217-
tag_url="https://api.github.com/repos/shadowsocks/shadowsocks-libev/releases/latest"
225+
tag_url="${V6_PROXY}https://api.github.com/repos/shadowsocks/shadowsocks-libev/releases/latest"
218226
new_ver="$(normalizeVersion "$(curl -s "${tag_url}" --connect-timeout 10| grep 'tag_name' | cut -d\" -f4)")"
219227
ssPath=`which ss-server`
220228
if [[ "$?" != "0" ]]; then
@@ -233,9 +241,9 @@ installSS() {
233241

234242
mkdir -p /etc/shadowsocks-libev
235243
ssPath=`which ss-server`
236-
cat > /etc/shadowsocks-libev/config.json<<-EOF
244+
cat > $CONFIG_FILE<<-EOF
237245
{
238-
"server":"0.0.0.0",
246+
"server":"::",
239247
"server_port":${PORT},
240248
"local_port":1080,
241249
"password":"${PASSWORD}",
@@ -257,7 +265,7 @@ Wants=network-online.target
257265
Type=simple
258266
PIDFile=/var/run/shadowsocks-libev.pid
259267
LimitNOFILE=32768
260-
ExecStart=$ssPath -c /etc/shadowsocks-libev/config.json -f /var/run/shadowsocks-libev.pid
268+
ExecStart=$ssPath -c $CONFIG_FILE -f /var/run/shadowsocks-libev.pid
261269
ExecReload=/bin/kill -s HUP \$MAINPID
262270
ExecStop=/bin/kill -s TERM \$MAINPID
263271
@@ -291,22 +299,21 @@ setFirewall() {
291299
}
292300

293301
info() {
294-
ip=`curl -sL -4 ip.sb`
295-
port=`cat /etc/shadowsocks-libev/config.json | grep server_port | cut -d: -f2 | tr -d \",' '`
302+
port=`grep server_port $CONFIG_FILE| cut -d: -f2 | tr -d \",' '`
296303
res=`netstat -nltp | grep ${port} | grep 'ss-server'`
297304
[[ -z "$res" ]] && status="${RED}已停止${PLAIN}" || status="${GREEN}正在运行${PLAIN}"
298-
password=`cat /etc/shadowsocks-libev/config.json | grep password | cut -d: -f2 | tr -d \",' '`
299-
method=`cat /etc/shadowsocks-libev/config.json | grep method | cut -d: -f2 | tr -d \",' '`
305+
password=`grep password $CONFIG_FILE| cut -d: -f2 | tr -d \",' '`
306+
method=`grep method $CONFIG_FILE| cut -d: -f2 | tr -d \",' '`
300307

301-
res=`echo -n "${method}:${password}@${ip}:${port}" | base64 -w 0`
308+
res=`echo -n "${method}:${password}@${IP}:${port}" | base64 -w 0`
302309
link="ss://${res}"
303310

304311
echo ============================================
305312
echo -e " ${BLUE}ss运行状态${PLAIN}${status}"
306-
echo -e " ${BLUE}ss配置文件:${PLAIN}${RED}/etc/shadowsocks-libev/config.json${PLAIN}"
313+
echo -e " ${BLUE}ss配置文件:${PLAIN}${RED}$CONFIG_FILE${PLAIN}"
307314
echo ""
308315
echo -e " ${RED}ss配置信息:${PLAIN}"
309-
echo -e " ${BLUE}IP(address):${PLAIN} ${RED}${ip}${PLAIN}"
316+
echo -e " ${BLUE}IP(address):${PLAIN} ${RED}${IP}${PLAIN}"
310317
echo -e " ${BLUE}端口(port):${PLAIN}${RED}${port}${PLAIN}"
311318
echo -e " ${BLUE}密码(password):${PLAIN}${RED}${password}${PLAIN}"
312319
echo -e " ${BLUE}加密方式(method):${PLAIN} ${RED}${method}${PLAIN}"

centos_install_ssr.sh

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,21 @@ YELLOW="\033[33m" # Warning message
99
BLUE="\033[36m" # Info message
1010
PLAIN='\033[0m'
1111

12+
V6_PROXY=""
13+
IP=`curl -4 ip.sb`
14+
if [[ "$?" != "0" ]]; then
15+
IP=`curl -6 ip.sb`
16+
V6_PROXY="https://cool-firefly-b19e.hijk.workers.dev/"
17+
fi
18+
1219
FILENAME="ShadowsocksR-v3.2.2"
13-
URL="https://github.com/shadowsocksrr/shadowsocksr/archive/3.2.2.tar.gz"
20+
URL="${V6_PROXY}https://github.com/shadowsocksrr/shadowsocksr/archive/3.2.2.tar.gz"
1421
BASE=`pwd`
1522

1623
OS=`hostnamectl | grep -i system | cut -d: -f2`
1724

25+
CONFIG_FILE="/etc/shadowsocksR.json"
26+
1827
colorEcho() {
1928
echo -e "${1}${@:2}${PLAIN}"
2029
}
@@ -288,10 +297,10 @@ installSSR() {
288297
cd ${BASE} && rm -rf shadowsocksr-3.2.2 ${FILENAME}.tar.gz
289298
fi
290299

291-
cat > /etc/shadowsocksR.json<<-EOF
300+
cat > $CONFIG_FILE<<-EOF
292301
{
293302
"server":"0.0.0.0",
294-
"server_ipv6":"[::]",
303+
"server_ipv6":"::",
295304
"server_port":${PORT},
296305
"local_port":1080,
297306
"password":"${PASSWORD}",
@@ -318,7 +327,7 @@ Wants=network-online.target
318327
[Service]
319328
Type=forking
320329
LimitNOFILE=32768
321-
ExecStart=/usr/local/shadowsocks/server.py -c /etc/shadowsocksR.json -d start
330+
ExecStart=/usr/local/shadowsocks/server.py -c $CONFIG_FILE -d start
322331
ExecReload=/bin/kill -s HUP \$MAINPID
323332
ExecStop=/bin/kill -s TERM \$MAINPID
324333
@@ -392,28 +401,27 @@ installBBR() {
392401
}
393402

394403
info() {
395-
ip=`curl -sL -4 ip.sb`
396-
port=`cat /etc/shadowsocksR.json | grep server_port | cut -d: -f2 | tr -d \",' '`
404+
port=`grep server_port $CONFIG_FILE| cut -d: -f2 | tr -d \",' '`
397405
res=`netstat -nltp | grep ${port} | grep python`
398406
[ -z "$res" ] && status="${RED}已停止${PLAIN}" || status="${GREEN}正在运行${PLAIN}"
399-
password=`cat /etc/shadowsocksR.json | grep password | cut -d: -f2 | tr -d \",' '`
400-
method=`cat /etc/shadowsocksR.json | grep method | cut -d: -f2 | tr -d \",' '`
401-
protocol=`cat /etc/shadowsocksR.json | grep protocol | cut -d: -f2 | tr -d \",' '`
402-
obfs=`cat /etc/shadowsocksR.json | grep obfs | cut -d: -f2 | tr -d \",' '`
407+
password=`grep password $CONFIG_FILE| cut -d: -f2 | tr -d \",' '`
408+
method=`grep method $CONFIG_FILE| cut -d: -f2 | tr -d \",' '`
409+
protocol=`grep protocol $CONFIG_FILE| cut -d: -f2 | tr -d \",' '`
410+
obfs=`grep obfs $CONFIG_FILE| cut -d: -f2 | tr -d \",' '`
403411

404412
p1=`echo -n ${password} | base64 -w 0`
405413
p1=`echo -n ${p1} | tr -d =`
406-
res=`echo -n "${ip}:${port}:${protocol}:${method}:${obfs}:${p1}/?remarks=&protoparam=&obfsparam=" | base64 -w 0`
414+
res=`echo -n "${IP}:${port}:${protocol}:${method}:${obfs}:${p1}/?remarks=&protoparam=&obfsparam=" | base64 -w 0`
407415
res=`echo -n ${res} | tr -d =`
408416
link="ssr://${res}"
409417

410418
echo ""
411419
echo ============================================
412420
echo -e " ${BLUE}ssr运行状态:${PLAIN}${status}"
413-
echo -e " ${BLUE}ssr配置文件:${PLAIN}${RED}/etc/shadowsocksR.json${PLAIN}"
421+
echo -e " ${BLUE}ssr配置文件:${PLAIN}${RED}$CONFIG_FILE${PLAIN}"
414422
echo ""
415423
echo -e " ${RED}ssr配置信息:${PLAIN}"
416-
echo -e " ${BLUE}IP(address):${PLAIN} ${RED}${ip}${PLAIN}"
424+
echo -e " ${BLUE}IP(address):${PLAIN} ${RED}${IP}${PLAIN}"
417425
echo -e " ${BLUE}端口(port):${PLAIN}${RED}${port}${PLAIN}"
418426
echo -e " ${BLUE}密码(password):${PLAIN}${RED}${password}${PLAIN}"
419427
echo -e " ${BLUE}加密方式(method):${PLAIN} ${RED}${method}${PLAIN}"
@@ -457,7 +465,7 @@ uninstall() {
457465
[ -z ${answer} ] && answer="n"
458466

459467
if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then
460-
rm -f /etc/shadowsocksR.json
468+
rm -f $CONFIG_FILE
461469
rm -f /var/log/shadowsocks.log
462470
rm -rf /usr/local/shadowsocks
463471
systemctl disable shadowsocksR && systemctl stop shadowsocksR && rm -rf /usr/lib/systemd/system/shadowsocksR.service

centos_install_v2ray.sh

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ PLAIN='\033[0m'
1010

1111
OS=`hostnamectl | grep -i system | cut -d: -f2`
1212

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+
1322
colorEcho() {
1423
echo -e "${1}${@:2}${PLAIN}"
1524
}
@@ -102,17 +111,17 @@ preinstall() {
102111

103112
installV2ray() {
104113
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)
106115

107-
if [ ! -f /etc/v2ray/config.json ]; then
116+
if [ ! -f $CONFIG_FILE ]; then
108117
colorEcho $RED " $OS 安装V2ray失败,请到 https://hijk.art 网站反馈"
109118
exit 1
110119
fi
111120

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
113122
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 \",' '`
116125
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
117126
ntpdate -u time.nist.gov
118127

@@ -173,34 +182,36 @@ installBBR() {
173182
fi
174183

175184
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
183194
}
184195

185196
info() {
186-
if [ ! -f /etc/v2ray/config.json ]; then
197+
if [ ! -f $CONFIG_FILE ]; then
187198
echo -e " ${RED}未安装v2ray!${PLAIN}"
188199
exit 1
189200
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 \",' '`
192203
res=`netstat -nltp | grep ${port} | grep v2ray`
193204
[ -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 \",' '`
198209
security="auto"
199210

200211
raw="{
201212
\"v\":\"2\",
202213
\"ps\":\"\",
203-
\"add\":\"$ip\",
214+
\"add\":\"$IP\",
204215
\"port\":\"${port}\",
205216
\"id\":\"${uid}\",
206217
\"aid\":\"$alterid\",
@@ -215,10 +226,10 @@ info() {
215226

216227
echo ============================================
217228
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}"
219230
echo ""
220231
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}"
222233
echo -e " ${BLUE}端口(port):${PLAIN} ${RED}${port}${PLAIN}"
223234
echo -e " ${BLUE}id(uuid):${PLAIN} ${RED}${uid}${PLAIN}"
224235
echo -e " ${BLUE}额外id(alterid):${PLAIN} ${RED}${alterid}${PLAIN}"

0 commit comments

Comments
 (0)