forked from helloxz/aria2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_aria2.sh
141 lines (131 loc) · 3.76 KB
/
install_aria2.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
#!/bin/bash
##### 一键安装aria2 + yaaw #####
##### Author:xiaoz.me #####
##### Update:2017-12-14 #####
#获取服务器IP
osip=$(curl -4s https://api.ip.sb/ip)
#安装函数
function centos(){
yum -y install curl
yum -y install epel-release
yum -y install aria2
}
#CentOS 6安装
function centos6(){
wget http://soft.xiaoz.org/linux/nettle-2.2-1.el6.rf.x86_64.rpm
wget http://soft.xiaoz.org/linux/nettle-devel-2.2-1.el6.rf.x86_64.rpm
wget http://soft.xiaoz.org/linux/gnutls-2.12.23-21.el6.x86_64.rpm
wget http://soft.xiaoz.org/linux/aria2-1.16.4-1.el6.rf.x86_64.rpm
rpm -ivh nettle-2.2-1.el6.rf.x86_64.rpm
rpm -ivh nettle-devel-2.2-1.el6.rf.x86_64.rpm
rpm -ivh gnutls-2.12.23-21.el6.x86_64.rpm
rpm -ivh aria2-1.16.4-1.el6.rf.x86_64.rpm
rm -rf *.rpm
}
#debian or ubuntu安装
function debian(){
apt-get -y install curl
apt-get -y install aria2
}
#Aria2低版本设置
function setting(){
mkdir -p /data/aria2
mkdir -p /data/aria2/download
touch /data/aria2/aria2.session
cp aria2.conf caddy.conf aria2.sh /data/aria2
echo "-------------------------------"
read -p "设置用户名:" user
read -p "设置密码:" pass
echo "-------------------------------"
sed -i "s/rpc-secret=/#rpc-secret=/g" /data/aria2/aria2.conf
sed -i "s/#rpc-user=/rpc-user=${user}/g" /data/aria2/aria2.conf
sed -i "s/#rpc-passwd=/rpc-passwd=${pass}/g" /data/aria2/aria2.conf
#下载yaaw
wget -P /data/aria2 https://github.com/helloxz/yaaw/archive/master.zip
cd /data/aria2
unzip master.zip
mv yaaw-master/* ./
#下载caddy server
wget http://soft.xiaoz.org/linux/caddy.filemanager -O caddy && mv caddy /usr/bin/
chmod +x /usr/bin/caddy
#修改配置
#sed -i "s/localhost/$1/g" /data/aria2/caddy.conf
sed -i "s/username/${user}/g" /data/aria2/caddy.conf
sed -i "s/password/${pass}/g" /data/aria2/caddy.conf
#放行端口
chk_firewall
#启动服务
cd /data/aria2
nohup aria2c --conf-path=/data/aria2/aria2.conf > /data/aria2/aria2.log 2>&1 &
nohup caddy -conf="/data/aria2/caddy.conf" > /data/aria2/caddy.log 2>&1 &
echo "-------------------------------"
echo "##### 安装完成,请牢记以下信息。 #####"
echo "访问地址:http://${osip}:6080"
echo "用户名:${user}"
echo "密码:${pass}"
echo "RPC地址:http://${user}:${pass}@$1:6800/jsonrpc"
echo "-------------------------------"
echo "需要帮助请访问:https://www.xiaoz.me/archives/9694"
echo "-------------------------------"
#一点点清理工作
rm -rf /data/aria2/*.zip
rm -rf /data/aria2/*.tar.gz
rm -rf /data/aria2/*.txt
rm -rf /data/aria2/*.md
rm -rf /data/aria2/yaaw-*
}
#自动放行端口
function chk_firewall() {
if [ -e "/etc/sysconfig/iptables" ]
then
iptables -I INPUT -p tcp --dport 6080 -j ACCEPT
iptables -I INPUT -p tcp --dport 6800 -j ACCEPT
iptables -I INPUT -p tcp --dport 51413 -j ACCEPT
service iptables save
service iptables restart
else
firewall-cmd --zone=public --add-port=6080/tcp --permanent
firewall-cmd --zone=public --add-port=6800/tcp --permanent
firewall-cmd --zone=public --add-port=51413/tcp --permanent
firewall-cmd --reload
fi
}
echo '##### 欢迎使用一键安装Aria2脚本^_^ #####'
echo '----------------------------------'
echo '请选择系统:'
echo "1) CentOS 7 X64"
echo "2) CentOS 6 X64"
echo "3) Debian 8+ X64 or Ubuntu 14+ X64"
echo "q) 退出"
echo '----------------------------------'
read -p ":" num
echo '----------------------------------'
case $num in
1)
#安装
centos
#设置
setting $osip
exit
;;
2)
#安装aria2
centos6
setting $osip
exit
;;
3)
debian
setting $osip
echo "温馨提示:Debian/Ubuntu用户若无法访问,需要放行 6080/6800/51413 端口或关闭防火墙!"
echo '----------------------------------'
exit
;;
q)
exit
;;
*)
echo '错误的参数'
exit
;;
esac