dccaa 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. ##### CCAA管理脚本 #####
  3. ##### Author:xiaoz.me #####
  4. ##### Update:2020-04-30 #####
  5. #导入环境变量
  6. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin
  7. export PATH
  8. aria2pid=$(pgrep 'aria2c')
  9. ccaa_web_pid=$(pgrep 'ccaa_web')
  10. filebrowser_pid=$(pgrep 'filebrowser')
  11. #设置aria2密码
  12. function pass(){
  13. sed -ir "s/rpc-secret=.*/rpc-secret=$PASS/g" /etc/ccaa/aria2.conf
  14. }
  15. #启动ccaa
  16. function ccaa_start(){
  17. nohup aria2c --conf-path=/etc/ccaa/aria2.conf > /var/log/aria2.log 2>&1 &
  18. nohup /usr/sbin/ccaa_web > /var/log/ccaa_web.log 2>&1 &
  19. nohup filebrowser -c /etc/ccaa/config.json > /var/log/fbrun.log 2>&1 &
  20. sleep 1
  21. }
  22. case $1 in
  23. 'start')
  24. ccaa_start
  25. ;;
  26. 'stop')
  27. kill -9 ${aria2pid}
  28. kill -9 ${ccaa_web_pid}
  29. kill -9 ${filebrowser_pid}
  30. ;;
  31. 'restart')
  32. kill -9 ${aria2pid}
  33. kill -9 ${ccaa_web_pid}
  34. kill -9 ${filebrowser_pid}
  35. ccaa_start
  36. ;;
  37. 'status')
  38. if [ "$aria2pid" == "" ]
  39. then
  40. echo "Not running!"
  41. else
  42. echo '-----------------------------------------------'
  43. echo "Aria2 is running,pid is ${aria2pid}."
  44. echo "AriaNg is running,pid is ${ccaa_web_pid}."
  45. echo "Filebrowser is running,pid is ${filebrowser_pid}."
  46. echo '-----------------------------------------------'
  47. fi
  48. ;;
  49. '-v')
  50. cat /etc/ccaa/version.txt && echo ''
  51. ;;
  52. 'pass')
  53. pass $2
  54. ;;
  55. *)
  56. echo '参数错误!'
  57. exit
  58. ;;
  59. esac