Skip to content

Commit

Permalink
分离删除脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
helloxz committed Feb 28, 2020
1 parent 8c83c2e commit 78cd4f0
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ccaa
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ aria2pid=$(pgrep 'aria2c')
ccaa_web_pid=$(pgrep 'ccaa_web')
filebrowser_pid=$(pgrep 'filebrowser')

#如果变量不存在
if [ ! $1 ]
then
bash <(curl -Ls https://raw.githubusercontent.com/helloxz/ccaa/master/ccaa.sh)
exit
fi

case $1 in
'start')
nohup aria2c --conf-path=/etc/ccaa/aria2.conf > /var/log/aria2.log 2>&1 &
Expand Down
15 changes: 15 additions & 0 deletions ccaa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin
export PATH

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

#安装之前的准备
function setout(){
if [ -e "/usr/bin/yum" ]
Expand Down Expand Up @@ -213,6 +227,7 @@ echo "q) 退出!"
read -p ":" istype
case $istype in
1)
check
setout
chk_firewall
install_aria2 && \
Expand Down
67 changes: 67 additions & 0 deletions uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/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')

#删除文件
rm -rf /etc/ccaa
rm -rf /usr/sbin/ccaa_web
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

#删除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

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

0 comments on commit 78cd4f0

Please sign in to comment.