autopt.sh 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. #!/bin/bash
  2. # 自动PT autopt.sh 一键脚本 短网址: https://git.io/autopt.sh
  3. # Usage: wget git.io/autopt.sh && bash autopt.sh
  4. SERVER_IP=172.17.0.1
  5. PORT=8080
  6. PASSWORD="adminadmin"
  7. # 此 Mongodb 数据连接帐号, 只供初次测试配置使用,请至 https://www.mongodb.com/ 注册私人免费帐号
  8. MONGODB_API="pt:[email protected]"
  9. RSS_DOMAIN="RSS.AUTOPT.NET"
  10. RSS_PASSKEY="123456789-PASSKEY-PASSKEY-ABCDEF"
  11. set_qb_conf()
  12. {
  13. echo -e "${SkyBlue}:: Docker版 qBittorrent Web 默认: ${GreenBG} http://${SERVER_IP}:${PORT} ${SkyBlue} 密码:${RedBG} ${PASSWORD} "
  14. echo -e "${SkyBlue}:: 请按实际信息修改,下面三项按 ${RedBG}<Enter>${SkyBlue} 使用默认值! ${Yellow}"
  15. read -p ":: 1.请输入 qBittorrent Web 服务器IP (172.17.0.1): " sv_ip
  16. read -p ":: 2.请输入 qBittorrent Web 服务端口 ( 8080 ) : " port
  17. read -p ":: 3.请输入 qBittorrent Web 管理密码 (adminadmin): " passwd
  18. if [[ ! -z "${sv_ip}" ]]; then
  19. SERVER_IP=${sv_ip}
  20. fi
  21. if [[ ! -z "${port}" ]]; then
  22. PORT=${port}
  23. fi
  24. if [[ ! -z "${passwd}" ]]; then
  25. PASSWORD=${passwd}
  26. fi
  27. echo -e "${SkyBlue}:: 设置后 qBittorrent Web管理网址: ${GreenBG} http://${SERVER_IP}:${PORT} ${SkyBlue} 密码:${RedBG} ${PASSWORD} "
  28. echo -e ${Font}
  29. }
  30. set_passkey_conf()
  31. {
  32. echo -e "${SkyBlue}:: 请提前登陆 PT 网站生成 RSS 订阅地址; 获得${GreenBG} PASSKEY ${SkyBlue}和RSS域名, 键盘按 ${RedBG}<Shift+Insert>${RedBG}${SkyBlue} 粘贴"
  33. echo -e "${SkyBlue}:: 请按实际信息修改,按 ${RedBG}<Enter>${SkyBlue} 使用伪值填充! ${Yellow}"
  34. read -p ":: 4.请输入RSS-PASSKEY (123456789-PASSKEY-PASSKEY-ABCDEF) : " passkey
  35. read -p ":: 5.请输入RSS 订阅地址的域名 ( pt.msg.vg ): " domain
  36. if [[ ! -z "${domain}" ]]; then
  37. RSS_DOMAIN=${domain}
  38. fi
  39. if [[ ! -z "${passkey}" ]]; then
  40. RSS_PASSKEY=${passkey}
  41. fi
  42. echo -e "${SkyBlue}:: 设置后RSS域名: ${GreenBG} ${RSS_DOMAIN} ${SkyBlue} RSS-PASSKEY: ${RedBG} ${RSS_PASSKEY} "
  43. echo -e ${Font}
  44. }
  45. input_conf(){
  46. set_qb_conf
  47. set_passkey_conf
  48. echo -e "${SkyBlue}:: 请检查填充信息是否正确, 即将初始化自动PT工具配置文件: ${GreenBG} /root/goseeder.conf ${Font} 请确认覆盖\c"
  49. read -p "(Y/N): " key
  50. case $key in
  51. Y)
  52. init_config
  53. ;;
  54. y)
  55. init_config
  56. ;;
  57. N)
  58. input_conf
  59. ;;
  60. n)
  61. input_conf
  62. ;;
  63. esac
  64. }
  65. init_config(){
  66. # 初始化自动PT工具配置文件: /root/goseeder.conf
  67. cat <<EOF >/root/goseeder.conf
  68. {
  69. "dbserver": "mongodb+srv://${MONGODB_API}.mongodb.net/myFirstDatabase?retryWrites=true&w=majority",
  70. "node": [
  71. {
  72. "source": "${RSS_DOMAIN}",
  73. "passkey": "${RSS_PASSKEY}",
  74. "limit": 10,
  75. "enable": true,
  76. "rule": {
  77. "seeder_time": 0,
  78. "seeder_ratio": 0,
  79. "speed_limit": 8.0
  80. }
  81. }
  82. ],
  83. "server": [
  84. {
  85. "endpoint": "http://${SERVER_IP}:${PORT}",
  86. "username": "admin",
  87. "password": "${PASSWORD}",
  88. "remark": "AutoPT-007",
  89. "enable": true,
  90. "rule": {
  91. "concurrent_download": 1,
  92. "disk_threshold": 10.0,
  93. "disk_overcommit": false,
  94. "max_speed": 30.00,
  95. "min_alivetime": 3600,
  96. "max_alivetime": 86400,
  97. "min_tasksize": 0.0,
  98. "max_tasksize": 50.0,
  99. "max_disklatency": 10000
  100. }
  101. }
  102. ]
  103. }
  104. EOF
  105. echo -e "${SkyBlue}:: 初始化自动PT工具配置文件完成: ${GreenBG} /root/goseeder.conf ${Font}"
  106. cat /root/goseeder.conf
  107. echo -e "${RedBG}# 此 Mongodb 数据连接帐号, 只供初次测试配置使用 ${SkyBlue} 请至 https://www.mongodb.com/ 注册私人免费帐号"
  108. }
  109. system_def(){
  110. Green="\033[32m" && Red="\033[31m" && GreenBG="\033[42;37m" && RedBG="\033[41;37m"
  111. Font="\033[0m" && Yellow="\033[0;33m" && SkyBlue="\033[0;36m"
  112. }
  113. install(){
  114. docker run -d --name autopt \
  115. --net=host \
  116. -v /root/goseeder.conf:/goseeder.conf \
  117. hongwenjun/autopt
  118. echo -e "${GreenBG}:: autopt镜像: https://hub.docker.com/r/hongwenjun/autopt ${Font}"
  119. }
  120. # 安装Docker可视化界面Portainer
  121. portainer_install(){
  122. docker run --name Portainer \
  123. --restart=always -d -p 9000:9000 \
  124. -v /var/run/docker.sock:/var/run/docker.sock \
  125. -v /opt/portainer_data:/data \
  126. portainer/portainer
  127. # 浏览器中输入网址管理
  128. echo -e "${GreenBG}:: Docker可视化界面Portainer 管理地址 ${Yellow}"
  129. echo -e http://$(cat /var/ip_addr):9000
  130. }
  131. # qBittorrent软件(Host模式支持IPV6)
  132. qbittorrent_install(){
  133. docker run --name=qbittorrent \
  134. -e PUID=1000 -e PGID=1000 \
  135. -e TZ=Asia/ShangHai \
  136. -e UMASK_SET=022 -e \
  137. WEBUI_PORT=8080 \
  138. --net=host \
  139. -v /mnt/config:/config \
  140. -v /mnt/downloads:/downloads \
  141. --restart unless-stopped \
  142. -d linuxserver/qbittorrent
  143. # 浏览器中输入网址管理
  144. echo -e "${GreenBG}:: qBittorrent软件 管理地址 ${Yellow}"
  145. echo -e http://$(cat /var/ip_addr):8080
  146. }
  147. # 设置菜单
  148. start_menu(){
  149. echo -e "${GreenBG}> 开源项目: https://github.com/hongwenjun/vps_setup "
  150. echo -e "${RedBG}> 自动PT autopt.sh 一键脚本 感谢大神TaterLi创作goseeder工具 ${Font}"
  151. echo -e "${SkyBlue}> 1. 重置初始化自动PT工具配置文件(首次需运行)"
  152. echo -e "> 2. 安装 Docker 容器 autopt 镜像"
  153. echo -e "> 3. 重启 autopt 自动PT容器"
  154. echo -e "> 4. 停止 autopt 自动PT容器"
  155. echo -e "> 5. 卸载 autopt 自动PT容器"
  156. echo -e "> 6. 查看 QB 服务器最新状态"
  157. echo "------------------------------------------------------------"
  158. echo -e "${Green}> 7. 安装Docker引擎和qBittorrent软件(Host模式支持IPV6)"
  159. echo -e "> 8. 检查 自动PT 推送信息, 可只按 ${RedBG}<Enter> ${Font}"
  160. echo -e "${Green}> 9. 安装Docker可视化界面 Portainer 工具 ${Font}"
  161. echo
  162. echo -e "${GreenBG}:: autopt镜像: https://hub.docker.com/r/hongwenjun/autopt ${Font}"
  163. read -p "请输入数字(1-8):" num
  164. case "$num" in
  165. 1)
  166. input_conf
  167. start_menu
  168. ;;
  169. 2)
  170. install
  171. start_menu
  172. ;;
  173. 3)
  174. docker restart autopt
  175. ;;
  176. 4)
  177. docker stop autopt
  178. ;;
  179. 5)
  180. docker rm -f autopt
  181. docker rmi -f hongwenjun/autopt
  182. ;;
  183. 6)
  184. docker exec -it autopt gostat
  185. ;;
  186. 7)
  187. ## 支持国内Docker安装,使用阿里云
  188. wget get.docker.com -O get.docker.sh
  189. bash get.docker.sh --mirror Aliyun
  190. qbittorrent_install
  191. ;;
  192. 8)
  193. docker logs --tail=100 autopt | grep -e 种子 -e 磁盘
  194. ;;
  195. 9)
  196. portainer_install
  197. ;;
  198. *)
  199. docker logs --tail=100 autopt | grep -e 种子 -e 磁盘
  200. ;;
  201. esac
  202. }
  203. clear
  204. system_def
  205. start_menu