forked from chinashiyu/gfw.press
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvultr_centos8.sh.txt
158 lines (117 loc) · 5.17 KB
/
vultr_centos8.sh.txt
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/sh
echo ;
echo ;
echo 正在安装翻墙大杀器服务,请稍候 ... ;
echo ;
if [ -e "/gfw.press" ] ; then
echo ;
echo "目录 /gfw.press 已经存在,安装退出" ;
echo ;
echo "如需重新安装,请先把目录 /gfw.press 改名或删除" ;
echo ;
echo ;
exit 1 ;
fi;
# 安装增强软件库
echo -n ▋▋ ;
yum install elrepo-release -y -q > /dev/null 2>&1 ;
yum install epel-release -y -q > /dev/null 2>&1 ;
yum update -y -q > /dev/null 2>&1 ;
# 安装语言环境
echo -n ▋▋ ;
yum install langpacks-zh_CN -y -q > /dev/null 2>&1 ;
echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf ;
echo 'LC_ALL="zh_CN.UTF-8"' >> /etc/locale.conf ;
# 安装密码生成鸡
echo -n ▋▋ ;
yum install pwgen net-tools -y -q > /dev/null 2>&1 ;
# 安装 Java 虚拟鸡
echo -n ▋▋ ;
yum install java-latest-openjdk-devel -y -q > /dev/null 2>&1 ;
# 安装 Git 源代码管理鸡
echo -n ▋▋ ;
yum install git -y -q > /dev/null 2>&1 ;
# 安装 Squid 代理服务鸡
echo -n ▋▋ ;
yum install squid -y -q > /dev/null 2>&1 ;
# 配置防火墙
echo -n ▋▋ ;
if [ "`firewall-cmd --query-port=10000-30000/tcp --permanent`" == "no" ]; then firewall-cmd --add-port=10000-30000/tcp --permanent > /dev/null 2>&1 ; firewall-cmd --reload > /dev/null 2>&1 ; fi ;
# 优化 Squid 代理服务鸡
echo -n ▋▋ ;
if [ -e "/etc/squid/squid.conf" ] && [ "`grep 'shutdown_lifetime 3 seconds' /etc/squid/squid.conf`" == "" ]; then
echo "" >> /etc/squid/squid.conf
echo "shutdown_lifetime 3 seconds" >> /etc/squid/squid.conf
echo "access_log none" >> /etc/squid/squid.conf
echo "cache_log /dev/null" >> /etc/squid/squid.conf
echo "logfile_rotate 0" >> /etc/squid/squid.conf
echo "cache deny all" >> /etc/squid/squid.conf
echo "cache_mem 0 MB" >> /etc/squid/squid.conf
echo "maximum_object_size_in_memory 0 KB" >> /etc/squid/squid.conf
echo "memory_cache_mode disk" >> /etc/squid/squid.conf
echo "memory_cache_shared off" >> /etc/squid/squid.conf
echo "memory_pools off" >> /etc/squid/squid.conf
echo "memory_pools_limit 0 MB" >> /etc/squid/squid.conf
echo "acl NCACHE method GET" >> /etc/squid/squid.conf
echo "no_cache deny NCACHE" >> /etc/squid/squid.conf
echo "acl flash rep_mime_type application/x-shockwave-flash" >> /etc/squid/squid.conf
echo "http_reply_access deny flash" >> /etc/squid/squid.conf
fi;
# 优化系统
echo -n ▋▋ ;
echo > /etc/security/limits.d/99-perf.conf ;
echo '* soft nproc 65536' >> /etc/security/limits.d/99-perf.conf ;
echo '* hard nproc 65536' >> /etc/security/limits.d/99-perf.conf ;
echo '* soft nofile 65536' >> /etc/security/limits.d/99-perf.conf ;
echo '* hard nofile 65536' >> /etc/security/limits.d/99-perf.conf ;
echo > /etc/sysctl.d/99-perf.conf ;
echo 'net.ipv4.tcp_congestion_control=bbr' >> /etc/sysctl.d/99-perf.conf ;
echo 'net.core.default_qdisc=fq' >> /etc/sysctl.d/99-perf.conf ;
echo 'net.core.rmem_max=134217728' >> /etc/sysctl.d/99-perf.conf ;
echo 'net.core.wmem_max=134217728' >> /etc/sysctl.d/99-perf.conf ;
echo 'net.core.somaxconn=1024' >> /etc/sysctl.d/99-perf.conf ;
echo 'net.core.netdev_max_backlog=1048576' >> /etc/sysctl.d/99-perf.conf ;
sysctl -p /etc/sysctl.d/99-perf.conf > /dev/null 2>&1 ;
tuned-adm profile network-latency > /dev/null 2>&1 ;
# 设置 Squid 代理服务鸡开机启动
echo -n ▋▋ ;
systemctl enable squid > /dev/null 2>&1 ;
# 启动 Squid 代理服务鸡
echo -n ▋▋ ;
systemctl start squid > /dev/null 2>&1 ;
# 下载和设置翻墙大杀器程序
echo -n ▋▋ ;
cd / > /dev/null 2>&1 ;
git clone -q https://github.com/chinashiyu/gfw.press.git > /dev/null 2>&1 ;
chmod a+x /gfw.press/server.sh > /dev/null 2>&1 ;
chmod a+x /gfw.press/stop.sh > /dev/null 2>&1 ;
for x in `for ((i=0;i<30;i++)); do expr $RANDOM % 20000 + 10000 ; done | sort -u`; do echo $x `pwgen -c -n -s -B 10 1`; done > /gfw.press/user.tx_ ;
rm -f /gfw.press/user.txt > /dev/null 2>&1 ;
cp /gfw.press/user.tx_ /gfw.press/user.txt > /dev/null 2>&1 ;
declare -i _mem ;
_mem=`free -m |grep Mem |awk '{print $2}'` ;
if (($_mem<600)); then
sed -i "s/-Xms512M/-Xms256M/g" /gfw.press/server.sh ;
sed -i "s/-Xmx512M/-Xmx256M/g" /gfw.press/server.sh ;
fi ;
if (($_mem>1800)); then
sed -i "s/-Xms512M/-Xms1024M/g" /gfw.press/server.sh ;
sed -i "s/-Xmx512M/-Xmx1024M/g" /gfw.press/server.sh ;
fi ;
# 设置翻墙大杀器服务开机启动
echo -n ▋▋ ;
sed -i "s/\/gfw.press\/server.sh//g" /etc/rc.d/rc.local ;
echo "/gfw.press/server.sh" >> /etc/rc.d/rc.local ;
chmod +x /etc/rc.d/rc.local ;
# 启动翻墙大杀器服务
echo -n ▋▋ ;
/gfw.press/server.sh
echo ;
echo ;
echo "恭喜你!已成功安装并启动翻墙大杀器服务" ;
echo ;
echo "查看端口密码请执行 cat /gfw.press/user.txt " ;
echo ;
echo "重新启动服务请执行 /gfw.press/server.sh " ;
echo ;
echo ;