uninstall.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. ##### 一键卸载CCAA #####
  3. ##### 作者:xiaoz.me #####
  4. ##### 更新时间:2020-02-28 #####
  5. #导入环境变量
  6. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin
  7. export PATH
  8. #删除端口函数
  9. function del_post() {
  10. if [ -e "/etc/sysconfig/iptables" ]
  11. then
  12. sed -i '/^.*6080.*/'d /etc/sysconfig/iptables
  13. sed -i '/^.*6081.*/'d /etc/sysconfig/iptables
  14. sed -i '/^.*6800.*/'d /etc/sysconfig/iptables
  15. sed -i '/^.*6998.*/'d /etc/sysconfig/iptables
  16. sed -i '/^.*51413.*/'d /etc/sysconfig/iptables
  17. service iptables save
  18. service iptables restart
  19. elif [ -e "/etc/firewalld/zones/public.xml" ]
  20. then
  21. firewall-cmd --zone=public --remove-port=6080/tcp --permanent
  22. firewall-cmd --zone=public --remove-port=6081/tcp --permanent
  23. firewall-cmd --zone=public --remove-port=6800/tcp --permanent
  24. firewall-cmd --zone=public --remove-port=6998/tcp --permanent
  25. firewall-cmd --zone=public --remove-port=51413/tcp --permanent
  26. firewall-cmd --reload
  27. elif [ -e "/etc/ufw/before.rules" ]
  28. then
  29. sudo ufw delete 6080/tcp
  30. sudo ufw delete 6081/tcp
  31. sudo ufw delete 6800/tcp
  32. sudo ufw delete 6998/tcp
  33. sudo ufw delete 51413/tcp
  34. fi
  35. }
  36. #停止所有服务
  37. kill -9 $(pgrep 'aria2c')
  38. kill -9 $(pgrep 'ccaa_web')
  39. kill -9 $(pgrep 'filebrowser')
  40. kill -9 $(pgrep 'caddy')
  41. systemctl disable aria2
  42. systemctl disable ccaa_web
  43. systemctl disable filebrowser
  44. #删除文件
  45. rm -rf /etc/ccaa
  46. rm -rf /usr/sbin/ccaa_web
  47. rm -rf /usr/sbin/ccaa
  48. rm -rf /usr/sbin/ccaa
  49. rm -rf /usr/bin/aria2c
  50. rm -rf aria2-1.*
  51. rm -rf AriaNg*
  52. rm -rf /usr/share/man/man1/aria2c.1
  53. rm -rf /etc/ssl/certs/ca-certificates.crt
  54. rm -rf /etc/systemd/system/aria2.service
  55. rm -rf /etc/systemd/system/ccaa_web.service
  56. rm -rf /etc/systemd/system/filebrowser.service
  57. #删除filebrowser
  58. rm -rf /usr/sbin/filebrowser
  59. #删除日志
  60. rm -rf /var/log/aria2.log
  61. rm -rf /var/log/ccaa_web.log
  62. rm -rf /var/log/fbrun.log
  63. rm -rf /var/log/filebrowser.log
  64. #删除用户和用户组
  65. userdel ccaa
  66. groupdel ccaa
  67. #删除端口
  68. del_post
  69. echo "------------------------------------------------"
  70. echo '卸载完成!'
  71. echo "------------------------------------------------"
  72. #删除自身
  73. rm -rf ccaa-uninstall.sh