ccaa 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. ##### CCAA管理脚本 #####
  3. ##### Author:xiaoz.me #####
  4. ##### Update:2020-02-27 #####
  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. #如果变量不存在
  12. if [ ! $1 ]
  13. then
  14. bash <(curl -Lsk https://raw.githubusercontent.com/helloxz/ccaa/master/ccaa.sh)
  15. exit
  16. fi
  17. case $1 in
  18. 'start')
  19. nohup sudo -u ccaa aria2c --conf-path=/etc/ccaa/aria2.conf > /var/log/aria2.log 2>&1 &
  20. nohup sudo -u ccaa /usr/sbin/ccaa_web > /var/log/ccaa_web.log 2>&1 &
  21. nohup sudo -u ccaa filebrowser -c /etc/ccaa/config.json > /var/log/fbrun.log 2>&1 &
  22. exit
  23. ;;
  24. 'stop')
  25. kill -9 ${aria2pid}
  26. kill -9 ${ccaa_web_pid}
  27. kill -9 ${filebrowser_pid}
  28. ;;
  29. 'restart')
  30. kill -9 ${aria2pid}
  31. kill -9 ${ccaa_web_pid}
  32. kill -9 ${filebrowser_pid}
  33. nohup sudo -u ccaa aria2c --conf-path=/etc/ccaa/aria2.conf > /var/log/aria2.log 2>&1 &
  34. nohup sudo -u ccaa /usr/sbin/ccaa_web > /var/log/ccaa_web.log 2>&1 &
  35. nohup sudo -u ccaa filebrowser -c /etc/ccaa/config.json > /var/log/fbrun.log 2>&1 &
  36. exit;
  37. ;;
  38. 'status')
  39. if [ "$aria2pid" == "" ]
  40. then
  41. echo "Not running!"
  42. else
  43. echo '-----------------------------------------------'
  44. echo "Aria2 is running,pid is ${aria2pid}."
  45. echo "AriaNg is running,pid is ${ccaa_web_pid}."
  46. echo "Filebrowser is running,pid is ${filebrowser_pid}."
  47. echo '-----------------------------------------------'
  48. fi
  49. ;;
  50. '-v')
  51. cat /etc/ccaa/version.txt && echo ''
  52. ;;
  53. *)
  54. echo '参数错误!'
  55. exit
  56. ;;
  57. esac