Linux一键安装Aria2 + AriaNg + Filebrowser

2020年05月18日

转自hostloc,ID:xiaoz
CCAA原为CentOS + Caddy + AriaNg + Aria2,故命名为CCAA,不过现在已经不仅仅支持CentOS,包括主流的Debian、Ubuntu也已经支持,自2.0(2020/02/28)版本开始已移除Caddy,改用Golang写了一个简单的WebServer来运行AriaNg。

主要功能
支持HTTP/HTTPS/FTP/BT/磁力链接等离线下载,断点续传等
文件管理、视频在线播放
完善的帮助文档

安装CCAA

#海外
bash <(curl -Lsk https://raw.githubusercontent.com/helloxz/ccaa/master/ccaa.sh)
#国内
bash <(curl -Lsk https://raw.githubusercontent.com/helloxz/ccaa/master/ccaa.sh) cdn

 

2.0更新内容

    优化安装脚本
    更新aria2版本
    更新Filebrowser版本
    更新AriaNG版本
    移除Caddy,改用Golang写了一个简单的WebServer来运行AriaNG
    CentOS 8支持
    修复一些BUG

升级方法

在2020.02.28之前的理论上都是1.0,升级2.0的办法是执行一键脚本,根据提示卸载。然后再次执行脚本安装即可升级2.0,哈哈哈。

更多介绍可访问:https://www.xiaoz.me/archives/14336
项目地址:https://github.com/helloxz/ccaa
帮助文档:https://www.yuque.com/helloz/ccaa

Docker安装

docker run --name="ccaa" -d -p 6080:6080 -p 6081:6081 -p 6800:6800 -p 51413:51413 \
    -v /data/ccaaDown:/data/ccaaDown \
    -e PASS="xiaoz.me" \
    helloz/ccaa \
    sh -c "dccaa pass && dccaa start"

 

常用命令

    ccaa:进入CCAA操作界面
    ccaa status:查看CCAA运行状态
    ccaa stop:停止CCAA
    ccaa start:启动CCAA
    ccaa restart:重启CCAA
    ccaa -v:查看CCAA版本(2.0开始支持)

ccaa.sh脚本内容

#!/bin/bash
#####	一键安装File Browser + Aria2 + AriaNg		#####
#####	作者:xiaoz.me						#####
#####	更新时间:2020-02-27				#####

#导入环境变量
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin
export PATH

#CDN域名设置
if [ $1 = 'cdn' ]
	then
	aria2_url='https://soft.xiaoz.top/linux/aria2-1.35.0-linux-gnu-64bit-build1.tar.bz2'
	filebrowser_url='https://soft.xiaoz.top/linux/linux-amd64-filebrowser.tar.gz'
	master_url='https://github.com/helloxz/ccaa/archive/master.zip'
	ccaa_web_url='https://soft.xiaoz.top/linux/ccaa_web.tar.gz'
	else
	aria2_url='https://github.com/q3aql/aria2-static-builds/releases/download/v1.35.0/aria2-1.35.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='https://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
		#更新软件,否则可能make命令无法安装
		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
}
#安装Aria2
function install_aria2(){
	#进入临时目录
	cd ./ccaa_tmp
	#yum -y update
	#安装aria2静态编译版本,来源于https://github.com/q3aql/aria2-static-builds/
	wget -c ${aria2_url}
	tar jxvf aria2-1.35.0-linux-gnu-64bit-build1.tar.bz2
	cd aria2-1.35.0-linux-gnu-64bit-build1
	make install
	cd
}

#安装File Browser文件管理器
function install_file_browser(){
	cd ./ccaa_tmp
	#下载File Browser
	wget ${filebrowser_url}
	#解压
	tar -zxvf linux-amd64-filebrowser.tar.gz
	#移动位置
	mv filebrowser /usr/sbin
	cd
}
#处理配置文件
function dealconf(){
	cd ./ccaa_tmp
	#下载CCAA项目
	wget ${master_url}
	#解压
	unzip master.zip
	#复制CCAA核心目录
	mv ccaa-master/ccaa_dir /etc/ccaa
	#创建aria2日志文件
	touch /var/log/aria2.log
	#upbt增加执行权限
	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
	#如果Aria2密钥为空
	while [ -z "${secret}" ]
	do
		read -p "Aria2 RPC 密钥:(字母或数字组合,不要含有特殊字符):" secret
	done
	
	#如果下载路径为空,设置默认下载路径
	if [ -z "${downpath}" ]
	then
		downpath='/data/ccaaDown'
	fi

	#获取ip
	osip=$(curl -4s https://api.ip.sb/ip)
	
	#执行替换操作
	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
	#替换filebrowser读取路径
	sed -i "s%ccaaDown%${downpath}%g" /etc/ccaa/config.json
	#替换AriaNg服务器链接
	sed -i "s/server_ip/${osip}/g" /etc/ccaa/AriaNg/index.html
	
	#更新tracker
	bash /etc/ccaa/upbt.sh
	
	#安装AriaNg
	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 caddy -conf="/etc/ccaa/caddy.conf" > /etc/ccaa/caddy.log 2>&1 &
	nohup sudo -u ccaa /usr/sbin/ccaa_web > /var/log/ccaa_web.log 2>&1 &
	#运行filebrowser
	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 "大功告成,请访问: https://${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
	#rm -rf *.conf
	#rm -rf init
}

#卸载
function uninstall(){
	wget -O ccaa-uninstall.sh https://raw.githubusercontent.com/helloxz/ccaa/master/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

 

docker-ccaa.sh脚本内容

#!/bin/sh
#####	一键安装File Browser + Aria2 + AriaNg		#####
#####	作者:xiaoz.me						#####
#####	更新时间:2020-02-27				#####

#导入环境变量
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin
export PATH

#各种路径设置
aria2_url='https://github.com/q3aql/aria2-static-builds/releases/download/v1.35.0/aria2-1.35.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='https://soft.xiaoz.org/linux/ccaa_web'

#安装前的检查
function check(){
	echo '-------------------------------------------------------------'
	if [ -e "/etc/ccaa" ]
        then
        echo 'CCAA已经安装,若需要重新安装,请先卸载再安装!'
        echo '-------------------------------------------------------------'
        exit
	else
	        echo '检测通过,即将开始安装。'
	        echo '-------------------------------------------------------------'
	fi
}

#安装之前的准备
function setout(){
	#安装需要的软件
	apk add curl wget zip tar make bzip2 unzip
	#创建临时目录
	cd
	mkdir ./ccaa_tmp
	#创建用户和用户组
}
#安装Aria2
function install_aria2(){
	#进入临时目录
	cd ./ccaa_tmp
	#yum -y update
	#安装aria2静态编译版本,来源于https://github.com/q3aql/aria2-static-builds/
	wget -c ${aria2_url}
	tar jxvf aria2-1.35.0-linux-gnu-64bit-build1.tar.bz2
	cd aria2-1.35.0-linux-gnu-64bit-build1
	make install
	cd
}

#安装File Browser文件管理器
function install_file_browser(){
	cd ./ccaa_tmp
	#下载File Browser
	wget ${filebrowser_url}
	#解压
	tar -zxvf linux-amd64-filebrowser.tar.gz
	#移动位置
	mv filebrowser /usr/sbin
	cd
}
#处理配置文件
function dealconf(){
	cd ./ccaa_tmp
	#下载CCAA项目
	wget ${master_url}
	#解压
	unzip master.zip
	#复制CCAA核心目录
	mv ccaa-master/ccaa_dir /etc/ccaa
	#创建aria2日志文件
	touch /var/log/aria2.log
	#upbt增加执行权限
	chmod +x /etc/ccaa/upbt.sh
	chmod +x ccaa-master/ccaa
	cp ccaa-master/dccaa /usr/sbin
	chmod +x /usr/sbin/dccaa
	cd
}

#设置账号密码
function setting(){
	cd
	cd ./ccaa_tmp
	echo '-------------------------------------------------------------'

	#获取ip
	osip=$(curl -4s https://api.ip.sb/ip)
	
	#执行替换操作
	downpath='/data/ccaaDown'
	mkdir -p ${downpath}
	sed -i "s%dir=%dir=${downpath}%g" /etc/ccaa/aria2.conf
	sed -ir "s/rpc-secret=.*/rpc-secret=$PASS/g" /etc/ccaa/aria2.conf
	#替换filebrowser读取路径
	sed -i "s%ccaaDown%${downpath}%g" /etc/ccaa/config.json
	#替换AriaNg服务器链接
	#sed -i "s/server_ip/${osip}/g" /etc/ccaa/AriaNg/index.html
	rm -rf /etc/ccaa/AriaNg/index.html
	mv /etc/ccaa/AriaNg/dindex.html /etc/ccaa/AriaNg/index.html
	#更新tracker
	sh /etc/ccaa/upbt.sh
	
	#安装AriaNg
	wget ${ccaa_web_url}
	#tar -zxvf ccaa_web.tar.gz
	cp ccaa_web /usr/sbin/
	chmod +x /usr/sbin/ccaa_web

	#启动服务
	#nohup aria2c --conf-path=/etc/ccaa/aria2.conf > /var/log/aria2.log 2>&1 &
	#nohup caddy -conf="/etc/ccaa/caddy.conf" > /etc/ccaa/caddy.log 2>&1 &
	#nohup /usr/sbin/ccaa_web > /var/log/ccaa_web.log 2>&1 &
	#运行filebrowser
	#nohup filebrowser -c /etc/ccaa/config.json > /var/log/fbrun.log 2>&1 &

	echo '-------------------------------------------------------------'
	echo "大功告成,请访问: https://${osip}:6080/"
	echo 'File Browser 用户名:ccaa'
	echo 'File Browser 密码:admin'
	echo 'Aria2 RPC 密钥:' $PASS
	echo '帮助文档: https://dwz.ovh/ccaa (必看)' 
	echo '-------------------------------------------------------------'
}
#清理工作
function cleanup(){
	cd
	rm -rf ccaa_tmp
	#rm -rf *.conf
	#rm -rf init
}

#卸载
function uninstall(){
	wget -O ccaa-uninstall.sh https://raw.githubusercontent.com/helloxz/ccaa/master/uninstall.sh
	sh 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 $1 in
    'install') 
    	check
    	setout
    	install_aria2 && \
    	install_file_browser && \
    	dealconf && \
    	setting && \
    	cleanup
    ;;
    'uninstall') 
    	uninstall
    ;;
    'upbt') 
    	sh /etc/ccaa/upbt.sh
    ;;
    'q') 
    	exit
    ;;
    *) echo '参数错误!'
esac

 

uninstall.sh脚本内容

#!/bin/bash
#####	一键卸载CCAA		#####
#####	作者:xiaoz.me						#####
#####	更新时间:2020-02-28				#####

#导入环境变量
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin
export PATH

#删除端口函数
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
}

#停止所有服务
kill -9 $(pgrep 'aria2c')
kill -9 $(pgrep 'ccaa_web')
kill -9 $(pgrep 'filebrowser')
kill -9 $(pgrep 'caddy')
systemctl disable aria2
systemctl disable ccaa_web
systemctl disable filebrowser

#删除文件
rm -rf /etc/ccaa
rm -rf /usr/sbin/ccaa_web
rm -rf /usr/sbin/ccaa
rm -rf /usr/sbin/ccaa
rm -rf /usr/bin/aria2c
rm -rf aria2-1.*
rm -rf AriaNg*
rm -rf /usr/share/man/man1/aria2c.1
rm -rf /etc/ssl/certs/ca-certificates.crt
rm -rf /etc/systemd/system/aria2.service
rm -rf /etc/systemd/system/ccaa_web.service
rm -rf /etc/systemd/system/filebrowser.service

#删除filebrowser
rm -rf /usr/sbin/filebrowser

#删除日志
rm -rf /var/log/aria2.log
rm -rf /var/log/ccaa_web.log
rm -rf /var/log/fbrun.log
rm -rf /var/log/filebrowser.log

#删除用户和用户组
userdel ccaa
groupdel ccaa

#删除端口
del_post
echo "------------------------------------------------"
echo '卸载完成!'
echo "------------------------------------------------"

#删除自身
rm -rf ccaa-uninstall.sh

 


sicnature ---------------------------------------------------------------------
Your current IP address is: 3.88.211.227
Your IP address location: 美国弗吉尼亚阿什本
Your IP address country and region: 美国 美国
Your current browser is:
Your current system is:
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source http://www.myzhenai.com/post/3337.html

没有评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注