docker-ccaa.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 ipv4.ip.sb)
  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 'Aria2 RPC 密钥:' $PASS
  112. echo '帮助文档: https://dwz.ovh/ccaa (必看)'
  113. echo '-------------------------------------------------------------'
  114. }
  115. #清理工作
  116. function cleanup(){
  117. cd
  118. rm -rf ccaa_tmp
  119. #rm -rf *.conf
  120. #rm -rf init
  121. }
  122. #卸载
  123. function uninstall(){
  124. wget -O ccaa-uninstall.sh https://raw.githubusercontent.com/helloxz/ccaa/master/uninstall.sh
  125. sh ccaa-uninstall.sh
  126. }
  127. #选择安装方式
  128. echo "------------------------------------------------"
  129. echo "Linux + File Browser + Aria2 + AriaNg一键安装脚本(CCAA)"
  130. echo "1) 安装CCAA"
  131. echo "2) 卸载CCAA"
  132. echo "3) 更新bt-tracker"
  133. echo "q) 退出!"
  134. #read -p ":" istype
  135. case $1 in
  136. 'install')
  137. check
  138. setout
  139. install_aria2 && \
  140. install_file_browser && \
  141. dealconf && \
  142. setting && \
  143. cleanup
  144. ;;
  145. 'uninstall')
  146. uninstall
  147. ;;
  148. 'upbt')
  149. sh /etc/ccaa/upbt.sh
  150. ;;
  151. 'q')
  152. exit
  153. ;;
  154. *) echo '参数错误!'
  155. esac