forked from wlhost/ss-panel-v3-mod_Uim-1
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.sh
408 lines (402 loc) · 15.8 KB
/
test.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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
#ss-panel-v3-mod_UIChanges 官方dev版本
#Author: 十一
#Blog: blog.67cc.cn
#Time:2018-8-25 11:05:33
#!/bin/bash
#check root
[ $(id -u) != "0" ] && { echo "错误: 您必须以root用户运行此脚本"; exit 1; }
function check_system(){
if [[ -f /etc/redhat-release ]]; then
release="centos"
elif cat /etc/issue | grep -q -E -i "debian"; then
release="debian"
elif cat /etc/issue | grep -q -E -i "ubuntu"; then
release="ubuntu"
elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
release="centos"
elif cat /proc/version | grep -q -E -i "debian"; then
release="debian"
elif cat /proc/version | grep -q -E -i "ubuntu"; then
release="ubuntu"
elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
release="centos"
fi
bit=`uname -m`
if [[ ${release} == "centos" ]] && [[ ${bit} == "x86_64" ]]; then
echo -e "你的系统为[${release} ${bit}],检测${Green} 可以 ${Font}搭建。"
else
echo -e "你的系统为[${release} ${bit}],检测${Red} 不可以 ${Font}搭建。"
echo -e "${Yellow} 正在退出脚本... ${Font}"
exit 0;
fi
}
function install_ss_panel_mod_UIm(){
yum remove httpd -y
yum install unzip zip git -y
wget -c --no-check-certificate https://raw.githubusercontent.com/marisn2017/ss-panel-v3-mod_Uim/master/lnmp1.5.zip && unzip lnmp1.5.zip && rm -rf lnmp1.5.zip && cd lnmp1.5 && chmod +x install.sh && ./install.sh lnmp
cd /home/wwwroot/
cp -r default/phpmyadmin/ . #复制数据库
cd default
rm -rf index.html
yum update nss curl iptables -y
#克隆项目 官方dev版本
git clone https://github.com/NimaQu/ss-panel-v3-mod_Uim.git tmp && mv tmp/.git . && rm -rf tmp && git reset --hard
#复制配置文件
# cp config/.config.php.example config/.config.php
#修改配置文件
# wget -c --no-check-certificate https://raw.githubusercontent.com/marisn2017/ss-panel-v3-mod_Uim/master/revise.sh && bash revise.sh
wget -N -P /home/wwwroot/default/config/ -c --no-check-certificate "https://raw.githubusercontent.com/marisn2017/ss-panel-v3-mod_Uim/master/config_new.php" -O .config.php
#移除防跨站攻击(open_basedir)
cd /home/wwwroot/default
chattr -i .user.ini
rm -rf .user.ini
sed -i 's/^fastcgi_param PHP_ADMIN_VALUE/#fastcgi_param PHP_ADMIN_VALUE/g' /usr/local/nginx/conf/fastcgi.conf
/etc/init.d/php-fpm restart
/etc/init.d/nginx reload
#设置文件权限
chown -R root:root *
chmod -R 777 *
chown -R www:www storage
#下载配置文件
wget -N -P /usr/local/nginx/conf/ --no-check-certificate "https://raw.githubusercontent.com/marisn2017/ss-panel-v3-mod_Uim/master/nginx.conf"
wget -N -P /usr/local/php/etc/ --no-check-certificate "https://raw.githubusercontent.com/marisn2017/ss-panel-v3-mod_Uim/master/php.ini"
#开启scandir()函数
sed -i 's/,scandir//g' /usr/local/php/etc/php.ini
service nginx restart #重启Nginx
# mysql -uroot -proot -e"create database sspanel;"
# mysql -uroot -proot -e"use sspanel;"
# mysql -uroot -proot sspanel < /home/wwwroot/default/sql/sspanel.sql
mysql -hlocalhost -uroot -proot <<EOF
create database sspanel;
use sspanel;
source /home/wwwroot/default/sql/glzjin_all.sql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
flush privileges;
EOF
cd /home/wwwroot/default
#安装composer
php composer.phar install
mv tool/alipay-f2fpay vendor/
mv -f tool/cacert.pem vendor/guzzle/guzzle/src/Guzzle/Http/Resources/
#mv -f tool/autoload_classmap.php vendor/composer/
wget -N -P /home/wwwroot/default/vendor/composer --no-check-certificate "https://raw.githubusercontent.com/marisn2017/ss-panel-v3-mod_Uim/master/autoload_classmap.php"
php xcat syncusers #同步用户
php xcat initQQWry #下载IP解析库
php xcat resetTraffic #重置流量
php xcat initdownload #下载ssr程式
#创建监控
yum -y install vixie-cron crontabs
rm -rf /var/spool/cron/root
echo 'SHELL=/bin/bash' >> /var/spool/cron/root
echo 'PATH=/sbin:/bin:/usr/sbin:/usr/bin' >> /var/spool/cron/root
echo '*/20 * * * * /usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1' >> /var/spool/cron/root
echo '0 0 * * * php -n /home/wwwroot/default/xcat dailyjob' >> /var/spool/cron/root
echo '*/1 * * * * php /home/wwwroot/default/xcat checkjob' >> /var/spool/cron/root
echo "*/1 * * * * php /home/wwwroot/default/xcat syncnode" >> /var/spool/cron/root
echo '30 22 * * * php /home/wwwroot/default/xcat sendDiaryMail' >> /var/spool/cron/root
/sbin/service crond restart
if [ -d "/home/wwwroot/default/" ];then
clear
echo "${Green}ss-panel-v3-mod_UIChanges安装成功~${Font}"
echo
echo -e "\033[1;5;31m请手动运行cd /home/wwwroot/default && php xcat createAdmin创建管理用户\033[0m"
else
echo "${Red}安装失败,请格盘重装~${Font}"
fi
}
function Libtest(){
#自动选择下载节点
GIT='raw.githubusercontent.com'
LIB='download.libsodium.org'
GIT_PING=`ping -c 1 -w 1 $GIT|grep time=|awk '{print $7}'|sed "s/time=//"`
LIB_PING=`ping -c 1 -w 1 $LIB|grep time=|awk '{print $7}'|sed "s/time=//"`
echo "$GIT_PING $GIT" > ping.pl
echo "$LIB_PING $LIB" >> ping.pl
libAddr=`sort -V ping.pl|sed -n '1p'|awk '{print $2}'`
if [ "$libAddr" == "$GIT" ];then
libAddr='https://raw.githubusercontent.com/marisn2017/ss-panel-v3-mod_Uim/master/libsodium-1.0.13.tar.gz'
else
libAddr='https://download.libsodium.org/libsodium/releases/libsodium-1.0.16.tar.gz'
fi
rm -f ping.pl
}
function Get_Dist_Version()
{
if [ -s /usr/bin/python3 ]; then
Version=`/usr/bin/python3 -c 'import platform; print(platform.linux_distribution()[1][0])'`
elif [ -s /usr/bin/python2 ]; then
Version=`/usr/bin/python2 -c 'import platform; print platform.linux_distribution()[1][0]'`
fi
}
function python_test(){
#测速决定使用哪个源
tsinghua='pypi.tuna.tsinghua.edu.cn'
pypi='mirror-ord.pypi.io'
doubanio='pypi.doubanio.com'
pubyun='pypi.pubyun.com'
tsinghua_PING=`ping -c 1 -w 1 $tsinghua|grep time=|awk '{print $8}'|sed "s/time=//"`
pypi_PING=`ping -c 1 -w 1 $pypi|grep time=|awk '{print $8}'|sed "s/time=//"`
doubanio_PING=`ping -c 1 -w 1 $doubanio|grep time=|awk '{print $8}'|sed "s/time=//"`
pubyun_PING=`ping -c 1 -w 1 $pubyun|grep time=|awk '{print $8}'|sed "s/time=//"`
echo "$tsinghua_PING $tsinghua" > ping.pl
echo "$pypi_PING $pypi" >> ping.pl
echo "$doubanio_PING $doubanio" >> ping.pl
echo "$pubyun_PING $pubyun" >> ping.pl
pyAddr=`sort -V ping.pl|sed -n '1p'|awk '{print $2}'`
if [ "$pyAddr" == "$tsinghua" ]; then
pyAddr='https://pypi.tuna.tsinghua.edu.cn/simple'
elif [ "$pyAddr" == "$pypi" ]; then
pyAddr='https://mirror-ord.pypi.io/simple'
elif [ "$pyAddr" == "$doubanio" ]; then
pyAddr='http://pypi.doubanio.com/simple --trusted-host pypi.doubanio.com'
elif [ "$pyAddr" == "$pubyun_PING" ]; then
pyAddr='http://pypi.pubyun.com/simple --trusted-host pypi.pubyun.com'
fi
rm -f ping.pl
}
# 一键添加SS-panel节点
function install_centos_ssr(){
cd /root
Get_Dist_Version
if [ $Version == "7" ]; then
wget --no-check-certificate https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
else
wget --no-check-certificate https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -ivh epel-release-latest-6.noarch.rpm
fi
rm -rf *.rpm
yum -y update --exclude=kernel*
yum -y install git gcc python-setuptools lsof lrzsz python-devel libffi-devel openssl-devel iptables
yum -y update nss curl libcurl
yum -y groupinstall "Development Tools"
#第一次yum安装 supervisor pip
yum -y install supervisor python-pip
supervisord
#第二次pip supervisor是否安装成功
if [ -z "`pip`" ]; then
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py
rm -rf *.py
fi
if [ -z "`ps aux|grep supervisord|grep python`" ]; then
pip install supervisor
supervisord
fi
#第三次检测pip supervisor是否安装成功
if [ -z "`pip`" ]; then
if [ -z "`easy_install`"]; then
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
fi
easy_install pip
fi
if [ -z "`ps aux|grep supervisord|grep python`" ]; then
easy_install supervisor
supervisord
fi
pip install --upgrade pip
Libtest
wget --no-check-certificate $libAddr
tar xf libsodium-1.0.13.tar.gz && cd libsodium-1.0.13
./configure && make -j2 && make install
echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
#清理文件
cd /root && rm -rf libsodium*
git clone -b manyuser https://github.com/NimaQu/shadowsocks.git "/root/shadowsocks"
cd /root/shadowsocks
chkconfig supervisord on
#第一次安装
python_test
pip install -r requirements.txt -i $pyAddr
#第二次检测是否安装成功
if [ -z "`python -c 'import requests;print(requests)'`" ]; then
pip install -r requirements.txt #用自带的源试试再装一遍
fi
#第三次检测是否成功
if [ -z "`python -c 'import requests;print(requests)'`" ]; then
cd /root && mkdir python && cd python
git clone https://github.com/shazow/urllib3.git && cd urllib3
python setup.py install && cd ..
git clone https://github.com/nakagami/CyMySQL.git && cd CyMySQL
python setup.py install && cd ..
git clone https://github.com/requests/requests.git && cd requests
python setup.py install && cd ..
git clone https://github.com/pyca/pyopenssl.git && cd pyopenssl
python setup.py install && cd ..
git clone https://github.com/cedadev/ndg_httpsclient.git && cd ndg_httpsclient
python setup.py install && cd ..
git clone https://github.com/etingof/pyasn1.git && cd pyasn1
python setup.py install && cd ..
rm -rf python
fi
systemctl stop firewalld.service
systemctl disable firewalld.service
cd /root/shadowsocks
cp apiconfig.py userapiconfig.py
cp config.json user-config.json
}
function install_ubuntu_ssr(){
apt-get update -y
apt-get install supervisor lsof -y
apt-get install build-essential wget -y
apt-get install iptables git -y
Libtest
wget --no-check-certificate $libAddr
tar xf libsodium-1.0.13.tar.gz && cd libsodium-1.0.13
./configure && make -j2 && make install
echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
apt-get install python-pip git -y
pip install cymysql
cd /root
git clone -b manyuser https://github.com/NimaQu/shadowsocks.git "/root/shadowsocks"
cd shadowsocks
pip install -r requirements.txt
chmod +x *.sh
# 配置程序
cp apiconfig.py userapiconfig.py
cp config.json user-config.json
}
function install_node(){
clear
#Check Root
[ $(id -u) != "0" ] && { echo "Error: You must be root to run this script"; exit 1; }
#check OS version
check_sys(){
if [[ -f /etc/redhat-release ]]; then
release="centos"
elif cat /etc/issue | grep -q -E -i "debian"; then
release="debian"
elif cat /etc/issue | grep -q -E -i "ubuntu"; then
release="ubuntu"
elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
release="centos"
elif cat /proc/version | grep -q -E -i "debian"; then
release="debian"
elif cat /proc/version | grep -q -E -i "ubuntu"; then
release="ubuntu"
elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
release="centos"
fi
}
install_ssr_for_each(){
check_sys
if [[ ${release} = "centos" ]]; then
install_centos_ssr
else
install_ubuntu_ssr
fi
}
# 取消文件数量限制
sed -i '$a * hard nofile 512000\n* soft nofile 512000' /etc/security/limits.conf
echo -e "如果以下手动配置错误,请在${config}手动编辑修改"
read -p "请输入你的对接域名或IP(例如:http://www.baidu.com 如果是本机请直接回车): " WEBAPI_URL
read -p "请输入muKey(在你的配置文件中 如果是本机请直接回车):" WEBAPI_TOKEN
read -p "请输入测速周期(回车默认为每6小时测速):" SPEEDTEST
read -p "请输入你的节点编号(非常重要,必须填,不能回车): " NODE_ID
install_ssr_for_each
IPAddress=`wget http://members.3322.org/dyndns/getip -O - -q ; echo`;
cd /root/shadowsocks
echo -e "modify Config.py...\n"
WEBAPI_URL=${WEBAPI_URL:-"http://${IPAddress}"}
sed -i '/WEBAPI_URL/c \WEBAPI_URL = '\'${WEBAPI_URL}\''' ${config}
#sed -i "s#https://zhaoj.in#${WEBAPI_URL}#" /root/shadowsocks/userapiconfig.py
WEBAPI_TOKEN=${WEBAPI_TOKEN:-"marisn"}
sed -i '/WEBAPI_TOKEN/c \WEBAPI_TOKEN = '\'${WEBAPI_TOKEN}\''' ${config}
#sed -i "s#glzjin#${WEBAPI_TOKEN}#" /root/shadowsocks/userapiconfig.py
SPEEDTEST=${SPEEDTEST:-"6"}
sed -i '/SPEED/c \SPEEDTEST = '${SPEEDTEST}'' ${config}
NODE_ID=${NODE_ID:-"3"}
sed -i '/NODE_ID/c \NODE_ID = '${NODE_ID}'' ${config}
#sed -i '2d' /root/shadowsocks/userapiconfig.py
#sed -i "2a\NODE_ID = ${NODE_ID}" /root/shadowsocks/userapiconfig.py
# 启用supervisord守护
supervisorctl shutdown
#某些机器没有echo_supervisord_conf
wget -N -P /etc/ --no-check-certificate https://raw.githubusercontent.com/marisn2017/ss-panel-v3-mod_Uim/master/supervisord.conf
supervisord
#iptables
iptables -F
iptables -X
iptables -I INPUT -p tcp -m tcp --dport 22:65535 -j ACCEPT
iptables -I INPUT -p udp -m udp --dport 22:65535 -j ACCEPT
iptables-save >/etc/sysconfig/iptables
echo 'iptables-restore /etc/sysconfig/iptables' >> /etc/rc.local
echo "/usr/bin/supervisord -c /etc/supervisord.conf" >> /etc/rc.local
chmod +x /etc/rc.d/rc.local
echo "#############################################################"
echo "# 安装完成,节点即将重启使配置生效 #"
echo "#############################################################"
reboot now
}
function install_BBR(){
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh&&chmod +x bbr.sh&&./bbr.sh
}
function install_RS(){
wget -N --no-check-certificate https://github.com/91yun/serverspeeder/raw/master/serverspeeder.sh && bash serverspeeder.sh
}
function NEW_NODE(){
wget -N --no-check-certificate https://raw.githubusercontent.com/marisn2017/ss-panel-v3-mod_Uim/master/node.sh && bash node.sh
}
#常规变量
update_time="2018年11月10日21:17:29"
config="/root/shadowsocks/userapiconfig.py"
#fonts color
Green="\033[32m"
Red="\033[31m"
Yellow="\033[33m"
GreenBG="\033[42;37m"
RedBG="\033[41;37m"
Font="\033[0m"
#notification information
Info="${Green}[Info]${Font}"
OK="${Green}[OK]${Font}"
Error="${Red}[Error]${Font}"
Notification="${Yellow}[Notification]${Font}"
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
ulimit -c 0
rm -rf script*
clear
check_system
sleep 2
echo -e "脚本最后更新时间:${Green} ${update_time} ${Font}"
echo -e "\033[31m#############################################################\033[0m"
echo -e "\033[32m#欢迎使用一键ss-panel-v3-mod_UIChanges搭建脚本 and 节点添加 #\033[0m"
echo -e "\033[34m#Blog: http://blog.67cc.cn/ #\033[0m"
echo -e "\033[35m#请选择你要搭建的脚本: #\033[0m"
echo -e "\033[36m#1. 一键ss-panel-v3-mod_UIChanges搭建[此脚本为测试版] #\033[0m"
echo -e "\033[31m#2. 一键添加SS-panel节点[新版] #\033[0m"
echo -e "\033[36m#3. 一键添加SS-panel节点 #\033[0m"
echo -e "\033[35m#4. 一键 BBR加速 搭建 #\033[0m"
echo -e "\033[34m#5. 一键锐速破解版搭建 #\033[0m"
echo -e "\033[33m# PS:建议先搭建加速再搭建面板#\033[0m"
echo -e "\033[32m# 支持 Centos 7.x 系统#\033[0m"
echo -e "\033[31m#############################################################\033[0m"
echo
read num
if [[ $num == "1" ]]
then
echo -e "\033[1;5;31m此脚本为测试版本,如有问题请去博客留言解决\033[0m"
echo
echo -e "\033[1;5;31m请在此等候 5 秒...\033[0m"
sleep 5
install_ss_panel_mod_UIm
elif [[ $num == "2" ]]
then
NEW_NODE
elif [[ $num == "3" ]]
then
install_node
elif [[ $num == "4" ]]
then
install_BBR
elif [[ $num == "5" ]]
then
install_RS
else
echo '输入错误';
exit 0;
fi;