docker-ccaa.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #!/bin/sh
  2. ##### 一键安装File Browser + Aria2 + AriaNg #####
  3. ##### 作者:xiaoz.me #####
  4. ##### 更新时间:2020-02-27 #####
  5. #导入环境变量
  6. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin
  7. export PATH
  8. #各种路径设置
  9. aria2_url='https://github.com/q3aql/aria2-static-builds/releases/download/v1.35.0/aria2-1.35.0-linux-gnu-64bit-build1.tar.bz2'
  10. filebrowser_url='https://github.com/filebrowser/filebrowser/releases/download/v2.0.16/linux-amd64-filebrowser.tar.gz'
  11. master_url='https://github.com/helloxz/ccaa/archive/master.zip'
  12. ccaa_web_url='http://soft.xiaoz.org/linux/ccaa_web'
  13. #安装前的检查
  14. function check(){
  15. echo '-------------------------------------------------------------'
  16. if [ -e "/etc/ccaa" ]
  17. then
  18. echo 'CCAA已经安装,若需要重新安装,请先卸载再安装!'
  19. echo '-------------------------------------------------------------'
  20. exit
  21. else
  22. echo '检测通过,即将开始安装。'
  23. echo '-------------------------------------------------------------'
  24. fi
  25. }
  26. #安装之前的准备
  27. function setout(){
  28. #安装需要的软件
  29. apk add curl wget zip tar make bzip2 unzip
  30. #创建临时目录
  31. cd
  32. mkdir ./ccaa_tmp
  33. #创建用户和用户组
  34. }
  35. #安装Aria2
  36. function install_aria2(){
  37. #进入临时目录
  38. cd ./ccaa_tmp
  39. #yum -y update
  40. #安装aria2静态编译版本,来源于https://github.com/q3aql/aria2-static-builds/
  41. wget -c ${aria2_url}
  42. tar jxvf aria2-1.35.0-linux-gnu-64bit-build1.tar.bz2
  43. cd aria2-1.35.0-linux-gnu-64bit-build1
  44. make install
  45. cd
  46. }
  47. #安装File Browser文件管理器
  48. function install_file_browser(){
  49. cd ./ccaa_tmp
  50. #下载File Browser
  51. wget ${filebrowser_url}
  52. #解压
  53. tar -zxvf linux-amd64-filebrowser.tar.gz
  54. #移动位置
  55. mv filebrowser /usr/sbin
  56. cd
  57. }
  58. #处理配置文件
  59. function dealconf(){
  60. cd ./ccaa_tmp
  61. #下载CCAA项目
  62. wget ${master_url}
  63. #解压
  64. unzip master.zip
  65. #复制CCAA核心目录
  66. mv ccaa-master/ccaa_dir /etc/ccaa
  67. #创建aria2日志文件
  68. touch /var/log/aria2.log
  69. #upbt增加执行权限
  70. chmod +x /etc/ccaa/upbt.sh
  71. chmod +x ccaa-master/ccaa
  72. cp ccaa-master/dccaa /usr/sbin
  73. chmod +x /usr/sbin/dccaa
  74. cd
  75. }
  76. #设置账号密码
  77. function setting(){
  78. cd
  79. cd ./ccaa_tmp
  80. echo '-------------------------------------------------------------'
  81. #获取ip
  82. osip=$(curl -4s https://api.ip.sb/ip)
  83. #执行替换操作
  84. downpath='/data/ccaaDown'
  85. mkdir -p ${downpath}
  86. sed -i "s%dir=%dir=${downpath}%g" /etc/ccaa/aria2.conf
  87. sed -ir "s/rpc-secret=.*/rpc-secret=$PASS/g" /etc/ccaa/aria2.conf
  88. #替换filebrowser读取路径
  89. sed -i "s%ccaaDown%${downpath}%g" /etc/ccaa/config.json
  90. #替换AriaNg服务器链接
  91. #sed -i "s/server_ip/${osip}/g" /etc/ccaa/AriaNg/index.html
  92. rm -rf /etc/ccaa/AriaNg/index.html
  93. mv /etc/ccaa/AriaNg/dindex.html /etc/ccaa/AriaNg/index.html
  94. #更新tracker
  95. sh /etc/ccaa/upbt.sh
  96. #安装AriaNg
  97. wget ${ccaa_web_url}
  98. #tar -zxvf ccaa_web.tar.gz
  99. cp ccaa_web /usr/sbin/
  100. chmod +x /usr/sbin/ccaa_web
  101. #启动服务
  102. #nohup aria2c --conf-path=/etc/ccaa/aria2.conf > /var/log/aria2.log 2>&1 &
  103. #nohup caddy -conf="/etc/ccaa/caddy.conf" > /etc/ccaa/caddy.log 2>&1 &
  104. #nohup /usr/sbin/ccaa_web > /var/log/ccaa_web.log 2>&1 &
  105. #运行filebrowser
  106. #nohup filebrowser -c /etc/ccaa/config.json > /var/log/fbrun.log 2>&1 &
  107. echo '-------------------------------------------------------------'
  108. echo "大功告成,请访问: http://${osip}:6080/"
  109. echo 'File Browser 用户名:ccaa'
  110. echo 'File Browser 密码:admin'
  111. echo '帮助文档: https://dwz.ovh/ccaa (必看)'
  112. echo '-------------------------------------------------------------'
  113. }
  114. #清理工作
  115. function cleanup(){
  116. cd
  117. rm -rf ccaa_tmp
  118. #rm -rf *.conf
  119. #rm -rf init
  120. }
  121. #卸载
  122. function uninstall(){
  123. wget -O ccaa-uninstall.sh https://raw.githubusercontent.com/helloxz/ccaa/master/uninstall.sh
  124. sh ccaa-uninstall.sh
  125. }
  126. #选择安装方式
  127. echo "------------------------------------------------"
  128. echo "Linux + File Browser + Aria2 + AriaNg一键安装脚本(CCAA)"
  129. echo "1) 安装CCAA"
  130. echo "2) 卸载CCAA"
  131. echo "3) 更新bt-tracker"
  132. echo "q) 退出!"
  133. #read -p ":" istype
  134. case $1 in
  135. 'install')
  136. check
  137. setout
  138. install_aria2 && \
  139. install_file_browser && \
  140. dealconf && \
  141. setting && \
  142. cleanup
  143. ;;
  144. 'uninstall')
  145. uninstall
  146. ;;
  147. 'upbt')
  148. sh /etc/ccaa/upbt.sh
  149. ;;
  150. 'q')
  151. exit
  152. ;;
  153. *) echo '参数错误!'
  154. esac