|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin |
|
|
export PATH |
|
|
|
|
|
|
|
|
if [ $1 = 'cdn' ] |
|
|
then |
|
|
aria2_url='https://hf-mirror.com/colaibu/ccaa/resolve/main/aria2-1.36.0-linux-gnu-64bit-build1.tar.bz2' |
|
|
filebrowser_url='https://hf-mirror.com/colaibu/ccaa/resolve/main/linux-amd64-filebrowser.tar.gz' |
|
|
master_url='https://hf-mirror.com/colaibu/ccaa/resolve/main/master.zip' |
|
|
ccaa_web_url='https://hf-mirror.com/colaibu/ccaa/resolve/main/ccaa_web.tar.gz' |
|
|
else |
|
|
aria2_url='https://github.com/q3aql/aria2-static-builds/releases/download/v1.35.0/aria2-1.36.0-linux-gnu-64bit-build1.tar.bz2' |
|
|
filebrowser_url='https://github.com/filebrowser/filebrowser/releases/download/v2.0.16/linux-amd64-filebrowser.tar.gz' |
|
|
master_url='https://github.com/helloxz/ccaa/archive/master.zip' |
|
|
ccaa_web_url='http://soft.xiaoz.org/linux/ccaa_web.tar.gz' |
|
|
fi |
|
|
|
|
|
|
|
|
function check(){ |
|
|
echo '-------------------------------------------------------------' |
|
|
if [ -e "/etc/ccaa" ] |
|
|
then |
|
|
echo 'CCAA已经安装,若需要重新安装,请先卸载再安装!' |
|
|
echo '-------------------------------------------------------------' |
|
|
exit |
|
|
else |
|
|
echo '检测通过,即将开始安装。' |
|
|
echo '-------------------------------------------------------------' |
|
|
fi |
|
|
} |
|
|
|
|
|
|
|
|
function setout(){ |
|
|
if [ -e "/usr/bin/yum" ] |
|
|
then |
|
|
yum -y install curl gcc make bzip2 gzip wget unzip tar |
|
|
else |
|
|
|
|
|
sudo apt-get update |
|
|
sudo apt-get install -y curl make bzip2 gzip wget unzip sudo |
|
|
fi |
|
|
|
|
|
cd |
|
|
mkdir ./ccaa_tmp |
|
|
|
|
|
groupadd ccaa |
|
|
useradd -M -g ccaa ccaa -s /sbin/nologin |
|
|
} |
|
|
|
|
|
function install_aria2(){ |
|
|
|
|
|
cd ./ccaa_tmp |
|
|
|
|
|
|
|
|
wget -c ${aria2_url} |
|
|
tar jxvf aria2-1.36.0-linux-gnu-64bit-build1.tar.bz2 |
|
|
cd aria2-1.36.0-linux-gnu-64bit-build1 |
|
|
make install |
|
|
cd |
|
|
} |
|
|
|
|
|
|
|
|
function install_file_browser(){ |
|
|
cd ./ccaa_tmp |
|
|
|
|
|
wget ${filebrowser_url} |
|
|
|
|
|
tar -zxvf linux-amd64-filebrowser.tar.gz |
|
|
|
|
|
mv filebrowser /usr/sbin |
|
|
cd |
|
|
} |
|
|
|
|
|
function dealconf(){ |
|
|
cd ./ccaa_tmp |
|
|
|
|
|
wget ${master_url} |
|
|
|
|
|
unzip master.zip |
|
|
|
|
|
mv ccaa-master/ccaa_dir /etc/ccaa |
|
|
|
|
|
touch /var/log/aria2.log |
|
|
|
|
|
chmod +x /etc/ccaa/upbt.sh |
|
|
chmod +x ccaa-master/ccaa |
|
|
cp ccaa-master/ccaa /usr/sbin |
|
|
cd |
|
|
} |
|
|
|
|
|
function chk_firewall(){ |
|
|
if [ -e "/etc/sysconfig/iptables" ] |
|
|
then |
|
|
iptables -I INPUT -p tcp --dport 6080 -j ACCEPT |
|
|
iptables -I INPUT -p tcp --dport 6081 -j ACCEPT |
|
|
iptables -I INPUT -p tcp --dport 6800 -j ACCEPT |
|
|
iptables -I INPUT -p tcp --dport 6998 -j ACCEPT |
|
|
iptables -I INPUT -p tcp --dport 51413 -j ACCEPT |
|
|
service iptables save |
|
|
service iptables restart |
|
|
elif [ -e "/etc/firewalld/zones/public.xml" ] |
|
|
then |
|
|
firewall-cmd --zone=public --add-port=6080/tcp --permanent |
|
|
firewall-cmd --zone=public --add-port=6081/tcp --permanent |
|
|
firewall-cmd --zone=public --add-port=6800/tcp --permanent |
|
|
firewall-cmd --zone=public --add-port=6998/tcp --permanent |
|
|
firewall-cmd --zone=public --add-port=51413/tcp --permanent |
|
|
firewall-cmd --reload |
|
|
elif [ -e "/etc/ufw/before.rules" ] |
|
|
then |
|
|
sudo ufw allow 6080/tcp |
|
|
sudo ufw allow 6081/tcp |
|
|
sudo ufw allow 6800/tcp |
|
|
sudo ufw allow 6998/tcp |
|
|
sudo ufw allow 51413/tcp |
|
|
fi |
|
|
} |
|
|
|
|
|
function del_post() { |
|
|
if [ -e "/etc/sysconfig/iptables" ] |
|
|
then |
|
|
sed -i '/^.*6080.*/'d /etc/sysconfig/iptables |
|
|
sed -i '/^.*6081.*/'d /etc/sysconfig/iptables |
|
|
sed -i '/^.*6800.*/'d /etc/sysconfig/iptables |
|
|
sed -i '/^.*6998.*/'d /etc/sysconfig/iptables |
|
|
sed -i '/^.*51413.*/'d /etc/sysconfig/iptables |
|
|
service iptables save |
|
|
service iptables restart |
|
|
elif [ -e "/etc/firewalld/zones/public.xml" ] |
|
|
then |
|
|
firewall-cmd --zone=public --remove-port=6080/tcp --permanent |
|
|
firewall-cmd --zone=public --remove-port=6081/tcp --permanent |
|
|
firewall-cmd --zone=public --remove-port=6800/tcp --permanent |
|
|
firewall-cmd --zone=public --remove-port=6998/tcp --permanent |
|
|
firewall-cmd --zone=public --remove-port=51413/tcp --permanent |
|
|
firewall-cmd --reload |
|
|
elif [ -e "/etc/ufw/before.rules" ] |
|
|
then |
|
|
sudo ufw delete 6080/tcp |
|
|
sudo ufw delete 6081/tcp |
|
|
sudo ufw delete 6800/tcp |
|
|
sudo ufw delete 6998/tcp |
|
|
sudo ufw delete 51413/tcp |
|
|
fi |
|
|
} |
|
|
|
|
|
function add_service() { |
|
|
if [ -d "/etc/systemd/system" ] |
|
|
then |
|
|
cp /etc/ccaa/services/* /etc/systemd/system |
|
|
systemctl daemon-reload |
|
|
fi |
|
|
} |
|
|
|
|
|
function setting(){ |
|
|
cd |
|
|
cd ./ccaa_tmp |
|
|
echo '-------------------------------------------------------------' |
|
|
read -p "设置下载路径(请填写绝对地址,默认/data/ccaaDown):" downpath |
|
|
read -p "Aria2 RPC 密钥:(字母或数字组合,不要含有特殊字符):" secret |
|
|
|
|
|
while [ -z "${secret}" ] |
|
|
do |
|
|
read -p "Aria2 RPC 密钥:(字母或数字组合,不要含有特殊字符):" secret |
|
|
done |
|
|
|
|
|
|
|
|
if [ -z "${downpath}" ] |
|
|
then |
|
|
downpath='/data/ccaaDown' |
|
|
fi |
|
|
|
|
|
|
|
|
osip=$(curl ipv4.ip.sb) |
|
|
|
|
|
|
|
|
mkdir -p ${downpath} |
|
|
sed -i "s%dir=%dir=${downpath}%g" /etc/ccaa/aria2.conf |
|
|
sed -i "s/rpc-secret=/rpc-secret=${secret}/g" /etc/ccaa/aria2.conf |
|
|
|
|
|
sed -i "s%ccaaDown%${downpath}%g" /etc/ccaa/config.json |
|
|
|
|
|
sed -i "s/server_ip/${osip}/g" /etc/ccaa/AriaNg/index.html |
|
|
|
|
|
|
|
|
bash /etc/ccaa/upbt.sh |
|
|
|
|
|
|
|
|
wget ${ccaa_web_url} |
|
|
tar -zxvf ccaa_web.tar.gz |
|
|
cp ccaa_web /usr/sbin/ |
|
|
chmod +x /usr/sbin/ccaa_web |
|
|
|
|
|
|
|
|
nohup sudo -u ccaa aria2c --conf-path=/etc/ccaa/aria2.conf > /var/log/aria2.log 2>&1 & |
|
|
|
|
|
nohup sudo -u ccaa /usr/sbin/ccaa_web > /var/log/ccaa_web.log 2>&1 & |
|
|
|
|
|
nohup sudo -u ccaa filebrowser -c /etc/ccaa/config.json > /var/log/fbrun.log 2>&1 & |
|
|
|
|
|
|
|
|
chown -R ccaa:ccaa /etc/ccaa/ |
|
|
chown -R ccaa:ccaa ${downpath} |
|
|
|
|
|
|
|
|
add_service |
|
|
|
|
|
echo '-------------------------------------------------------------' |
|
|
echo "大功告成,请访问: http://${osip}:6080/" |
|
|
echo 'File Browser 用户名:ccaa' |
|
|
echo 'File Browser 密码:admin' |
|
|
echo 'Aria2 RPC 密钥:' ${secret} |
|
|
echo '帮助文档: https://dwz.ovh/ccaa (必看)' |
|
|
echo '-------------------------------------------------------------' |
|
|
} |
|
|
|
|
|
function cleanup(){ |
|
|
cd |
|
|
rm -rf ccaa_tmp |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function uninstall(){ |
|
|
wget -O ccaa-uninstall.sh https://hf-mirror.com/colaibu/ccaa/resolve/main/uninstall.sh |
|
|
bash ccaa-uninstall.sh |
|
|
} |
|
|
|
|
|
|
|
|
echo "------------------------------------------------" |
|
|
echo "Linux + File Browser + Aria2 + AriaNg一键安装脚本(CCAA)" |
|
|
echo "1) 安装CCAA" |
|
|
echo "2) 卸载CCAA" |
|
|
echo "3) 更新bt-tracker" |
|
|
echo "q) 退出!" |
|
|
read -p ":" istype |
|
|
case $istype in |
|
|
1) |
|
|
check |
|
|
setout |
|
|
chk_firewall |
|
|
install_aria2 && \ |
|
|
install_file_browser && \ |
|
|
dealconf && \ |
|
|
setting && \ |
|
|
cleanup |
|
|
;; |
|
|
2) |
|
|
uninstall |
|
|
;; |
|
|
3) |
|
|
bash /etc/ccaa/upbt.sh |
|
|
;; |
|
|
q) |
|
|
exit |
|
|
;; |
|
|
*) echo '参数错误!' |
|
|
esac |
|
|
|