forked from achaorg/PyOne_Mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·132 lines (119 loc) · 3.63 KB
/
install.sh
File metadata and controls
executable file
·132 lines (119 loc) · 3.63 KB
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
#!/etc/bash
function wget_exists(){
echo "1. 安装wget";
which wget > /dev/null 2>&1
if [ $? == 0 ]; then
echo "wget exist"
else
echo "wget dose not exist"
yum install wget
fi
}
function git_exists(){
echo "2. 安装git";
which git > /dev/null 2>&1
if [ $? == 0 ]; then
echo "git exist"
else
echo "git dose not exist"
yum install git
fi
}
#安装pip
function pip_exists(){
echo "3. 安装pip";
which pip > /dev/null 2>&1
if [ $? == 0 ]; then
echo "pip exist"
else
echo "pip dose not exist"
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
rm -rf get-pip.py
fi
}
#安装python依赖包
function install_(){
echo "4. 安装python依赖包";
pip install -r requirements.txt -U
}
#配置文件
function config_file(){
echo "5. 配置文件";
cur_dir=`pwd`
cp self_config.py.sample self_config.py
cp supervisord.conf.sample supervisord.conf
mkdir /var/run/supervisor
chmod +x /var/run/supervisor
sed -i "s|/root/PyOne|$cur_dir|" self_config.py
sed -i "s|/root/PyOne|$cur_dir|" supervisord.conf
}
#添加开机任务
function auto_boot(){
echo "6. 配置开机启动";
cur_dir=`pwd`
echo "supervisord -c $cur_dir/supervisord.conf" >> /etc/rc.d/rc.local
echo "sh /data/aria2/aria2.sh start" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
# sh /data/arai2/aria2.sh start
}
#安装aria2
function install_aria2(){
echo "7. 安装aria2";
which aria2c > /dev/null 2>&1
if [ $? == 0 ]; then
echo "检测到已安装aria2"
echo "请到后台配置aria2信息"
echo "如果您配置了aria2授权信息,请确保是rpc-secret模式!如果不是,则不能正常工作。"
echo "开启rpc-secret模式方法:"
echo " >1. 编辑aria2的配置文件,将rpc-secret这一行反注释,然后'rpc-secret='后面填写密码"
echo " >2. 将rpc-user和rpc-passwd注释掉"
echo " >3. 重启aria2"
else
git clone https://github.com/abbeyokgo/aria2_installer.git
cd aria2_installer
sh install_aria2.sh
echo "安装aria2完成"
echo "如果已经成功安装,请到后台配置aria2信息"
cd ..
rm -rf aria2_installer
fi
}
#开放端口
function open_port(){
if [ -e "/etc/sysconfig/iptables" ]
then
iptables -I INPUT -p tcp --dport 34567 -j ACCEPT
service iptables save
service iptables restart
else
firewall-cmd --zone=public --add-port=34567/tcp --permanent
firewall-cmd --reload
fi
}
#执行
wget_exists
git_exists
pip_exists
install_
config_file
auto_boot
install_aria2
open_port
yum install lsof
mkdir logs
echo "---------------------------------------------------------------"
echo "一键脚本运行完成!请检查以下文件:"
echo " > 1. self_config.py、supervisord.conf是否存在!"
echo " > 2. 检查self_config.py、supervisord.conf脚本里面的目录是否正确!"
echo " > 3. 请确保已经安装Nginx、Redis、MongoDB,并已经运行!"
echo " > 4. 检查/data/aria2是否存在。"
echo " > 5. 检查aria2是否运行:pgrep 'aria2c'"
echo " 如果aria2没有运行,运行:sh /data/aria2/aria2.sh start"
echo
echo "如果检查没有问题!在网站目录可运行以下脚本运行网站"
echo "supervisord -c supervisord.conf"
echo "---------------------------------------------------------------"
echo
echo "PyOne交流群:864996565"
echo "PyOne交流群TG:https://t.me/joinchat/JQOOug6MY11gy_MiXTmqIA"