forked from msl4437/MiWiFi-R1D-ShadowSocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
miwifi-r1d-install.sh
92 lines (81 loc) · 2.38 KB
/
miwifi-r1d-install.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
92
#!/bin/sh
rm -f $0
mount -o remount rw /
clear
echo "#############################################################"
echo "# Install Shadowsocks for Miwifi"
echo "#############################################################"
#config setting and save settings.
echo "#############################################################"
echo "#"
echo "# Please input your shadowsocks configuration"
echo "#"
echo "#############################################################"
echo ""
echo "请输入服务器IP:"
read serverip
echo "请输入服务器端口:"
read serverport
echo "请输入密码"
read shadowsockspwd
echo "请输入加密方式"
read method
# Config shadowsocks
if [ -f "/etc/shadowsocks.json" ]; then
rm -f /etc/shadowsocks.json
fi
cat > /etc/shadowsocks.json<<-EOF
{
"server" : "${serverip}",
"server_port" : "${serverport}",
"local_address":"0.0.0.0",
"local_port" : "1081",
"password" : "${shadowsockspwd}",
"timeout" : "600",
"method" : "${method}"
}
EOF
# Config shadowsocks init script
if [ -f "/etc/init.d/shadowsocks" ]; then
rm -f /etc/init.d/shadowsocks
fi
curl -o /etc/init.d/shadowsocks https://raw.githubusercontent.com/kiss4437/MiWiFi-R1D-ShadowSocks/master/shadowsocks
chmod +x /etc/init.d/shadowsocks
ln -s /etc/init.d/shadowsocks /bin/shadowsocks
#config dnsmasq
if [ ! -d "/etc/dnsmasq.d" ]; then
mkdir -p /etc/dnsmasq.d
fi
rm -rf /etc/dnsmasq.d/*
curl -o /etc/dnsmasq.d/gfw_ipset.conf https://raw.githubusercontent.com/kiss4437/MiWiFi-R1D-ShadowSocks/master/gfw_ipset.conf
chmod +x /etc/dnsmasq.d/gfw_ipset.conf
# Config dns2socks
curl -o /usr/bin/dns2socks https://raw.githubusercontent.com/kiss4437/MiWiFi-R1D-ShadowSocks/master/dns2socks
chmod +x /usr/bin/dns2socks
#赋予执行权限
chmod +x /usr/bin/ss-redir
chmod +x /usr/bin/ss-local
chmod +x /usr/bin/ss-tunnel
#config firewall
cp -f /etc/firewall.user /etc/firewall.user.bak
echo "ipset -N gfwlist iphash -! " >> /etc/firewall.user
echo "iptables -t nat -A PREROUTING -p tcp -m set --match-set gfwlist dst -j REDIRECT --to-port 1081" >> /etc/firewall.user
chmod +x /etc/firewall.user
#restart all service
/etc/init.d/dnsmasq restart
/etc/init.d/firewall restart
/etc/init.d/shadowsocks start
/etc/init.d/shadowsocks enable
#install successfully
ps | grep ss-redir | grep -v grep
if [ $? -ne 0 ]
then
echo ""
echo "Shadowsocks安装失败....!"
echo ""
else
echo ""
echo "Shadowsocks安装成功!"
echo ""
fi
exit 0