forked from achaorg/PyOne_Mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·281 lines (243 loc) · 10.7 KB
/
update.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
#!/etc/bash
#check system
check_system(){
if [[ -f /etc/redhat-release ]]; then
release="centos"
elif cat /etc/issue | grep -Eqi "debian"; then
release="debian"
elif cat /etc/issue | grep -Eqi "ubuntu"; then
release="ubuntu"
elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
release="centos"
elif cat /proc/version | grep -Eqi "debian"; then
release="debian"
elif cat /proc/version | grep -Eqi "ubuntu"; then
release="ubuntu"
elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
release="centos"
fi
}
#check version
check_version(){
if [[ -s /etc/redhat-release ]]; then
version=`cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'`
else
version=`grep -oE "[0-9.]+" /etc/issue | cut -d . -f 1`
fi
bit=`uname -m`
if [[ ${bit} = "x86_64" ]]; then
bit="64"
else
bit="32"
fi
if [[ "${release}" = "centos" && ${version} -ge 7 ]];then
echo -e "${Blue}当前系统为CentOS ${version}${Font} "
elif [[ "${release}" = "debian" && ${version} -ge 8 ]];then
echo -e "${Blue}当前系统为Debian ${version}${Font} "
elif [[ "${release}" = "ubuntu" && ${version} -ge 16 ]];then
echo -e "${Blue}当前系统为Ubuntu ${version}${Font} "
else
echo -e "${Red}脚本不支持当前系统,安装中断!${Font} "
exit 1
fi
for EXE in grep cut xargs systemctl ip awk
do
if ! type -p ${EXE}; then
echo -e "${Red}系统精简厉害,脚本自动退出${Font}"
exit 1
fi
done
}
check_system
check_version
#11.20
del_rubbish(){
python -c "from function import *;mon_db.down_db.delete_many({});"
}
#2019.01.10
update_sp(){
ps -aux | grep supervisord | awk '{print "kill -9 " $2}'|sh
rm -rf supervisord.conf
cp supervisord.conf.sample supervisord.conf
supervisord -c supervisord.conf
}
#2019.01.18
update_config(){
num=`cat self_config.py | grep "balance" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'balance="False"' >> self_config.py
fi
num=`cat self_config.py | grep "robots" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'robots="""
User-agent: *
Disallow: /
"""' >> self_config.py
fi
num=`cat self_config.py | grep "admin_prefix" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'admin_prefix="admin"' >> self_config.py
fi
num=`cat self_config.py | grep "thread_num" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'thread_num="5"' >> self_config.py
fi
num=`cat self_config.py | grep "verify_url" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'verify_url="False"' >> self_config.py
fi
num=`cat self_config.py | grep "show_redirect" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'show_redirect="exe"' >> self_config.py
fi
num=`cat self_config.py | grep "show_image" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'show_image="bmp,jpg,jpeg,png,gif"' >> self_config.py
fi
num=`cat self_config.py | grep "show_video" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'show_video="mp4,webm"' >> self_config.py
fi
num=`cat self_config.py | grep "show_dash" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'show_dash="avi,mpg,mpeg,rm,rmvb,mov,wmv,mkv,asf"' >> self_config.py
fi
num=`cat self_config.py | grep "show_audio" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'show_audio="ogg,mp3,wav,aac,flac,m4a"' >> self_config.py
fi
num=`cat self_config.py | grep "show_code" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'show_code="html,htm,php,py,css,go,java,js,json,txt,sh,md"' >> self_config.py
fi
num=`cat self_config.py | grep "show_doc" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'show_doc="csv,doc,docx,odp,ods,odt,pot,potm,potx,pps,ppsx,ppsxm,ppt,pptm,pptx,rtf,xls,xlsx"' >> self_config.py
fi
value=`cat /root/.aria2/aria2.conf | grep "rpc-secret=" | sed -e 's/\(.*\)=\(.*\)/\2/g'`
if [[ $value == "" ]]; then
secret=`cat self_config.py | grep "ARIA2_SECRET=" | sed -e 's/\(.*\)=\"\(.*\)\"/\2/g'`
sed -i "s/rpc-secret=/rpc-secret=${secret}/g" /root/.aria2/aria2.conf
fi
num=`cat self_config.py | grep "delete_after_upload" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'delete_after_upload="False"' >> self_config.py
fi
num=`cat self_config.py | grep "redirect_file" | wc -l`
if [ $num == 0 ]; then
echo '' >> self_config.py
echo 'redirect_file="False"' >> self_config.py
fi
}
#2019.02.15
upgrade_to4(){
echo '-------------------------------'
echo '2019.02.15,PyOne升级为4.0版本!!'
echo '2019.02.15之前安装的PyOne需重新安装!'
echo '-------------------------------'
}
#2019.02.16
upgrade(){
num=`ls | grep .install | wc -l`
if [ $num == 0 ]; then
touch .install
fi
update_config
if [[ "${release}" = "centos" ]]; then
yum install gcc libffi-devel python-devel openssl-devel lsof -y
else
apt update -y
apt install -y make git cron build-essential python-dev lsof unzip python-setuptools python-wheel libffi-devel libssl-dev
fi
pip install -r requirements.txt -U
}
change_redirect(){
sed -i 's/auth.pyone.me/pyoneauth.github.io/' self_config.py
}
restart(){
num=`ls /etc/systemd/system | grep pyone.service | wc -l`
if [ $num == 0 ]; then
supervisorctl -c supervisord.conf restart pyone
else
systemctl restart pyone
fi
}
#执行
upgrade_to4
upgrade
change_redirect
echo "2018.11.20更新版本,修复了磁力链接下载的bug&上传、展示有特殊字符的文件出问题的bug。"
echo "2018.11.21更新版本,优化磁力下载功能-可选下载文件。"
echo "2018.12.04更新版本,优化磁力下载界面"
echo "2018.12.10更新版本,修复特定分享目录后,二级目录设置密码出错的bug"
echo "2018.12.20更新版本,基础设置之后无需重启网站啦!如果你一直有保存之后不生效的问题,那么本次直接重启服务器吧!"
echo "2019.01.10更新版本,1. 修复防盗链失效的bug;2. 优化开机启动脚本。"
echo "2019.01.13更新版本,修复后台修改密码不生效的bug"
echo "2019.01.14更新版本,修复bug"
echo "2019.01.18更新版本,修复bug;添加搜索功能"
echo "2019.01.21更新版本,添加功能:后台直接添加盘符...避免小白添加配置出现各种问题"
echo "2019.01.23更新版本:修复设置了共享目录后设置README/HEAD/密码出错的bug;优化更新文件列表假死的bug"
echo "2019.01.24更新版本:支持设置加密文件夹下的文件;优化UI"
echo "2019.01.28更新版本:支持自定义代码!"
echo "2019.01.29更新版本:支持设置网站标题前缀;支持自定义主题(待更新设计标准)"
echo "2019.01.30更新版本:提交新主题"
echo "2019.02.15更新版本:新增一键卸载PyOne功能!"
echo "2019.02.16更新版本:优化PyOne4.0安装流程!"
echo "2019.02.19更新版本:优化细节"
echo "2019.02.20更新版本:1. 填坑!2. 后台可配置mongo和redis信息;3. 优化离线下载体验;4. 输出日志"
echo "2019.02.21更新版本:修复自定义代码bug"
echo "2019.02.22更新版本:优化离线下载功能(重启网站后任务不中断)"
echo "2019.02.23更新版本:1. 修复上传bug;2. 优化检测机制"
echo "2019.02.26更新版本:优化上传速度!"
echo "2019.02.27更新版本:修复创建文件夹bug"
echo "2019.02.28更新版本:美化500&404页面"
echo "2019.03.05更新版本:重构&优化上传界面"
echo "2019.03.08更新版本:优化逻辑&修复文件夹连级加密失效的bug&添加新主题"
echo "2019.03.14更新版本:后台输出实时日志&&一键升级PyOne"
echo "2019.03.15更新版本:修复bug&优化layui主题&可设置默认排序字段"
echo "2019.03.19更新版本:可自定义默认盘&可设置默认排序方法"
echo "2019.03.22更新版本:可能修复了离线下载一直占用内存的bug"
echo "2019.03.23更新版本:修复网页查看日志后一直驻后台的bug"
echo "2019.03.26更新版本:修复上一个版本带来的新bug"
echo "2019.05.07更新版本:1、修复若干bug,并带来若干bug;2、重磅更新:【网盘搬家(beta)】功能!!"
echo "2019.05.09更新版本:1、修复【网盘搬家】部分bug;2、修复【更新列表】增量更新不起效的bug;3、【更新列表】可选网盘更新啦!"
echo "2019.05.10更新版本:1、新增robots.txt自定义;2、离线下载功能独立出来"
echo "2019.05.11更新版本:1、修复离线下载bug;2、优化离线下载界面体验"
echo "2019.05.21更新版本:修复若干bug"
echo "2019.05.22更新版本:支持自定义后台路径(更安全)"
echo "2019.05.23更新版本:新增负载均衡功能!"
echo "2019.05.24更新版本:支持世纪互联版本onedrive"
echo "2019.05.25更新版本:参考olaindex,视频和音频出错自动加载&每25分钟重新加载一次"
echo "2019.05.28更新版本:修复开启负债均衡之后,文件名有特殊符号播放不了的bug"
echo "2019.05.29更新版本:支持自定义线程数"
echo "2019.05.31更新版本:新增功能:1)下载链接验证开关;优化:1)aria2信息不对时,无法添加任务"
echo "2019.06.13更新版本:新增功能:文件展示设置"
echo "2019.06.14更新版本:稍微完善一下日志记录;分享页面取消token验证;修复开启下载验证之后,后台文件打开失败的bug;新增内嵌窗口"
echo "2019.07.24更新版本:1. 优化安装脚本,适应Centos7、Debian9+、Ubuntu16+等系统;2、优化安装流程"
echo "2019.07.26更新版本:修复若干bug"
echo "2019.07.29更新版本:1. 修复上传文件bug;2. 添加自定义选项"
echo "2019.07.30更新版本:1. 支持pdf预览;2. 支持流量转发"
echo "2019.07.31更新版本:1. 优化流量转发; 2. PDF预览更换为pdf.js"
echo "---------------------------------------------------------------"
echo "更新完成!"
echo "如果网站无法访问,请检查config.py!"
echo "如果一直提示mongodb或者redis未运行,请自行安装lsof"
echo "---------------------------------------------------------------"
echo
echo "PyOne交流群:864996565"
echo "PyOne交流群TG:https://t.me/joinchat/JQOOug6MY11gy_MiXTmqIA"
echo "end"
restart