Skip to content

Commit

Permalink
Merge pull request wy580477#7 from wy580477/dev2
Browse files Browse the repository at this point in the history
Add auto-update rclone config file env & auto-backup config files
  • Loading branch information
wy580477 authored Apr 24, 2022
2 parents 1f8bdd9 + d573683 commit b228554
Show file tree
Hide file tree
Showing 22 changed files with 155 additions and 56 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ POST_MODE=move_remote
DRIVE_NAME=auto
VMESS_UUID=a3ac20a7-45fe-4656-97ee-937ffec46144
VMESS_PATH=/f495ba1f
TZ=UTC
TZ=Asia/Shanghai
RESTART_TIME=11:05
4 changes: 3 additions & 1 deletion .github/workflows/heroku-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ jobs:
usedocker: true
env_file: ".env"
env:
HD_RCLONE_CONFIG_BASE64: ${{secrets.RCLONE_CONFIG_BASE64}}
HD_RCLONE_CONFIG_BASE64: ${{secrets.RCLONE_CONFIG_BASE64}}
HD_HEROKU_APP_NAME: ${{secrets.HEROKU_APP_NAME}}
HD_HEROKU_API_KEY: ${{secrets.HEROKU_API_KEY}}
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ RUN apk add --no-cache curl caddy jq bash findutils runit rclone apache2-utils t
&& chmod +x /.aria2allinoneworkdir/service/*/run /.aria2allinoneworkdir/service/*/log/run /.aria2allinoneworkdir/aria2/*.sh /.aria2allinoneworkdir/*.sh /.aria2allinoneworkdir/luxa /.aria2allinoneworkdir/merge \
&& mv /.aria2allinoneworkdir/merge /usr/bin \
&& mv /.aria2allinoneworkdir/luxa /usr/bin \
&& ln -s /.aria2allinoneworkdir/service/* /etc/service/ \
&& mkdir -p /mnt/data/videos
&& ln -s /.aria2allinoneworkdir/service/* /etc/service/

ENTRYPOINT ["sh","/.aria2allinoneworkdir/entrypoint.sh"]
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
2. Aria2和Rclone多种联动模式,复制、移动、边做种边上传。
3. Rclone以daemon方式运行,可在WebUI上手动传输文件和实时监测传输情况。
4. Aria2和Rclone可以接入其它host上运行的AriaNg/RcloneNg等前端面板,方便多host集中管理控制。
5. ttyd网页终端,可命令行执行lux视频下载工具和其它命令。
6. log目录下有每个进程独立日志。
5. 每天自动更新Rclone配置文件变量,解决了token过期问题。
6. 可指定每天dyno重启时间。
7. 每隔5分钟自动备份相关配置文件到Rclone远程存储,dyno重启时尝试从远程恢复,实现了配置文件和下载任务列表的持久化。
8. ttyd网页终端,可命令行执行lux视频下载工具和其它命令。
9. log目录下有每个进程独立日志。
## 部署方式

**请勿使用本仓库直接部署**
Expand Down Expand Up @@ -63,6 +66,9 @@
| `VMESS_UUID` | `a3ac20a7-45fe-4656-97ee-937ffec46144` | Vmess协议UUID,务必修改,建议使用UUID工具生成 |
| `VMESS_PATH` | `/f495ba1f` | Vmess协议路径,不要包含敏感信息 |
| `TZ` | `UTC` | 时区,Asia/Shanghai为中国时区 |
| `HEROKU_API_KEY` | `` | Heroku账号API密钥,可选项,用于从dyno内部更新rclone配置文件变量。可从Heroku账号面板处获得,也可以用heroku cli命令heroku authorizations:create创建。 |
| `HEROKU_APP_NAME` | `` | Heroku APP名称,可选项,用于从dyno内部更新rclone配置文件变量。 |
| `RESTART_TIME` | `` | 指定更新Rclone配置文件的时间,用于配合上面两个变量,dyno也同时重启。格式为06:00,24小时制,时区为TZ变量所指定的时区。 |

对控制Aria2和Rclone联动模式的POST_MODE变量说明:
1. dummy模式为无操作,move模式为下载及做种完成后移动到本地finished目录。
Expand All @@ -80,18 +86,19 @@
luxa:使用aria2下载视频,速度更快,但部分视频和音频分离下载的站点(youtube、B站等)需要手动合并,下载完成后受POST_MODE变量控制。
merge:合并当前目录下视频和音频文件到remuxed目录下。
### 更多用法和注意事项
1. Heroku每24小时重启后恢复到部署时文件系统,所以除了变量外任何改动都建议在部署前在github仓库内修改
1. Heroku每24小时重启后恢复到部署时文件系统,尽管配置文件会自动备份和尝试恢复,除了变量外任何改动都建议在部署前在github仓库内修改
2. 修改Heroku app变量方法:在Heroku app页面上点击setting,再点击Reveal Config Vars即可修改。
3. Rclone配置文件末尾加上如下内容,可以在Rclone Web前端中挂载本地存储,方便手动上传。
3. 需要指定HEROKU_API_KEY、HEROKU_APP_NAME、RESTART_TIME三个变量,才能自动更新rclone配置文件token。
4. RESTART_TIME变量指定dyno重启时间,需要Heroku api key和Heroku app name变量配合才能工作。Dyno的重启不是严格遵循24小时间隔,前后有一定误差,所以仍可能在指定的时间之前一小段时间重启。
5. Rclone配置文件末尾加上如下内容,可以在Rclone Web前端中挂载本地存储,方便手动上传。
```
[local]
type = alias
remote = /mnt/data
```
3. Rclone Web前端手动传输文件方法是点击页面左侧Explorer,然后选双版面布局,打开两个Rclone存储配置,直接拖动文件即可。
4. 因为Heroku文件系统的临时性,Rclone无法更新token,所以每隔一段时间需要更新Rclone配置文件变量,不然token会过期。
5. 无法通过Rclone Web前端建立需要网页认证的存储配置。
6. content/aria2目录下,aria2_chs(en).conf为Aria2配置文件,按需要指定的语言环境变量选择版本修改。script.conf为Aria2自动化配置文件。修改script.conf可以设置aria2清理文件方式和Rclone上传目录。
7. 每次dyno启动自动更新BT tracker list,如果需要禁用,重命名或删除/content/aria2/tracker.sh文件。
8. content/homer_conf目录下是导航页设置文件homer_chs(en).yml和图标资源,新加入的图标,在设置文件中要以./assets/tools/example.png这样的路径调用。
9. Vmess协议AlterID为0,可用Vmess WS 80端口或者Vmess WS tls 443端口连接。Xray设置可以通过content/service/xray/run文件修改。Heroku国内直连很难,需要使用Cloudflare或其它方式中转。
6. Rclone Web前端手动传输文件方法是点击页面左侧Explorer,然后选双版面布局,打开两个Rclone存储配置,直接拖动文件即可。
7. 无法通过Rclone Web前端建立需要网页认证的存储配置。
8. content/aria2目录下,aria2_chs(en).conf为Aria2配置文件,按需要指定的语言环境变量选择版本修改。script.conf为Aria2自动化配置文件。修改script.conf可以设置aria2清理文件方式和Rclone上传目录。
9. 每次dyno启动自动更新BT tracker list,如果需要禁用,重命名或删除/content/aria2/tracker.sh文件。
10. content/homer_conf目录下是导航页设置文件homer_chs(en).yml和图标资源,新加入的图标,在设置文件中要以./assets/tools/example.png这样的路径调用。
11. Vmess协议AlterID为0,可用Vmess WS 80端口或者Vmess WS tls 443端口连接。Xray设置可以通过content/service/xray/run文件修改。Heroku国内直连很难,需要使用Cloudflare或其它方式中转。
15 changes: 15 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@
"TZ": {
"description": "Timezone",
"value": "UTC"
},
"RESTART_TIME": {
"description": "Dyno restart time",
"required": false,
"value": ""
},
"HEROKU_APP_NAME": {
"description": "Name of this heroku app",
"required": false,
"value": ""
},
"HEROKU_API_KEY": {
"description": "Your heroku api key",
"required": false,
"value": ""
}
},
"stack": "container"
Expand Down
4 changes: 2 additions & 2 deletions content/aria2/copy_remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ UPLOAD_FILE() {
if [ -f "${LOCAL_PATH}" ]; then
mkdir -p /mnt/data/finished
mv -vf "${LOCAL_PATH}" /mnt/data/finished/
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802${RCLONERC_PATH} operations/copyfile srcFs=/mnt/data/finished srcRemote="${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" dstRemote="${TASK_FILE_NAME}" _async=true
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802 operations/copyfile srcFs=/mnt/data/finished srcRemote="${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" dstRemote="${TASK_FILE_NAME}" _async=true
else
mkdir -p /mnt/data/finished
mv -vf "${LOCAL_PATH}" /mnt/data/finished/
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802${RCLONERC_PATH} sync/copy srcFs=/mnt/data/finished/"${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" _async=true
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802 sync/copy srcFs=/mnt/data/finished/"${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" _async=true
fi
RCLONE_EXIT_CODE=$?
if [ ${RCLONE_EXIT_CODE} -eq 0 ]; then
Expand Down
4 changes: 2 additions & 2 deletions content/aria2/copy_remote_first.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ UPLOAD_FILE() {
echo
)
if [ -f "${LOCAL_PATH}" ]; then
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802${RCLONERC_PATH} operations/copyfile srcFs=/mnt/data/downloads srcRemote="${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" dstRemote="${TASK_FILE_NAME}" _async=true
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802 operations/copyfile srcFs=/mnt/data/downloads srcRemote="${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" dstRemote="${TASK_FILE_NAME}" _async=true
else
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802${RCLONERC_PATH} sync/copy srcFs="${LOCAL_PATH}" dstFs="${REMOTE_PATH}" _async=true
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802 sync/copy srcFs="${LOCAL_PATH}" dstFs="${REMOTE_PATH}" _async=true
fi
RCLONE_EXIT_CODE=$?
if [ ${RCLONE_EXIT_CODE} -eq 0 ]; then
Expand Down
4 changes: 2 additions & 2 deletions content/aria2/copy_remote_other.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ UPLOAD_FILE() {
echo
)
if [ -f "${LOCAL_PATH}" ]; then
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802${RCLONERC_PATH} operations/copyfile srcFs=/mnt/data/downloads srcRemote="${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" dstRemote="${TASK_FILE_NAME}" _async=true
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802 operations/copyfile srcFs=/mnt/data/downloads srcRemote="${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" dstRemote="${TASK_FILE_NAME}" _async=true
else
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802${RCLONERC_PATH} sync/copy srcFs="${LOCAL_PATH}" dstFs="${REMOTE_PATH}" _async=true
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802 sync/copy srcFs="${LOCAL_PATH}" dstFs="${REMOTE_PATH}" _async=true
fi
RCLONE_EXIT_CODE=$?
if [ ${RCLONE_EXIT_CODE} -eq 0 ]; then
Expand Down
4 changes: 2 additions & 2 deletions content/aria2/core
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ TASK_GID=$1
FILE_NUM=$2
FILE_PATH=$3
ARIA2_CONF_DIR="$(dirname $0)"
ARIA2_CONF="/.aria2allinoneworkdir/aria2.conf"
ARIA2_CONF="/mnt/data/config/aria2.conf"
ARIA2_SESSION="/.aria2allinoneworkdir/aria2/aria2.session"
SCRIPT_CONF="/.aria2allinoneworkdir/aria2/script.conf"
SCRIPT_CONF="/mnt/data/config/script.conf"
RED_FONT_PREFIX="\033[31m"
LIGHT_GREEN_FONT_PREFIX="\033[1;32m"
YELLOW_FONT_PREFIX="\033[1;33m"
Expand Down
Binary file modified content/aria2/dht.dat
Binary file not shown.
4 changes: 2 additions & 2 deletions content/aria2/move_remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ UPLOAD_FILE() {
if [ -f "${LOCAL_PATH}" ]; then
mkdir -p /mnt/data/finished
mv -vf "${LOCAL_PATH}" /mnt/data/finished/
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802${RCLONERC_PATH} operations/movefile srcFs=/mnt/data/finished srcRemote="${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" dstRemote="${TASK_FILE_NAME}" _async=true
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802 operations/movefile srcFs=/mnt/data/finished srcRemote="${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" dstRemote="${TASK_FILE_NAME}" _async=true
else
mkdir -p /mnt/data/finished
mv -vf "${LOCAL_PATH}" /mnt/data/finished/
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802${RCLONERC_PATH} sync/move srcFs=/mnt/data/finished/"${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" _async=true
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802 sync/move srcFs=/mnt/data/finished/"${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" _async=true
fi
RCLONE_EXIT_CODE=$?
if [ ${RCLONE_EXIT_CODE} -eq 0 ]; then
Expand Down
4 changes: 2 additions & 2 deletions content/aria2/move_remote_only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ UPLOAD_FILE() {
echo
)
if [ -f "${LOCAL_PATH}" ]; then
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802${RCLONERC_PATH} operations/movefile srcFs="${DOWNLOAD_DIR}" srcRemote="${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" dstRemote="${TASK_FILE_NAME}" _async=true
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802 operations/movefile srcFs="${DOWNLOAD_DIR}" srcRemote="${TASK_FILE_NAME}" dstFs="${REMOTE_PATH}" dstRemote="${TASK_FILE_NAME}" _async=true
else
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802${RCLONERC_PATH} sync/move srcFs="${LOCAL_PATH}" dstFs="${REMOTE_PATH}" _async=true
rclone rc --user "${USER}" --pass "${PASSWORD}" --rc-addr=localhost:56802 sync/move srcFs="${LOCAL_PATH}" dstFs="${REMOTE_PATH}" _async=true
fi
RCLONE_EXIT_CODE=$?
if [ ${RCLONE_EXIT_CODE} -eq 0 ]; then
Expand Down
4 changes: 2 additions & 2 deletions content/caddy_init_chs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

DRIVE_NAME_AUTO="$(sed -n '1p' /.aria2allinoneworkdir/drive.conf | sed "s/\[//g" | sed "s/\]//g")"
DRIVE_NAME_AUTO="$(sed -n '1p' /mnt/data/config/rclone.conf | sed "s/\[//g" | sed "s/\]//g")"
if [ "${DRIVE_NAME}" = "auto" ]; then
DRIVENAME=${DRIVE_NAME_AUTO}
else
Expand All @@ -13,7 +13,7 @@ elif [ "${POST_MODE}" = "move" ]; then
sed -i "s|MODE_STATUS|<br />[move] 下载任务完成后移动到本地 finished 目录</b>|g" /.aria2allinoneworkdir/homer/assets/config.yml
elif [ "${POST_MODE}" = "custom" ]; then
sed -i "s|MODE_STATUS|<br />Aria2自动化模式: [custom] 自定义</b>|g" /.aria2allinoneworkdir/homer/assets/config.yml
elif [ ! -f "/.aria2allinoneworkdir/drive.conf" ]; then
elif [ ! -f "/mnt/data/config/rclone.conf" ]; then
sed -i "s|MODE_STATUS|<br />Aria2自动化模式:<br />未找到 Rclone 配置文件</b>|g" /.aria2allinoneworkdir/homer/assets/config.yml
elif [ "${POST_MODE}" = "copy_remote" ]; then
sed -i "s|MODE_STATUS|<br />Aria2自动化模式:<br />[copy_remote] 下载及做种完成后移动到本地finished目录, 然后复制到Rclone远程存储${DRIVENAME}</b>|g" /.aria2allinoneworkdir/homer/assets/config.yml
Expand Down
4 changes: 2 additions & 2 deletions content/caddy_init_en.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

DRIVE_NAME_AUTO="$(sed -n '1p' /.aria2allinoneworkdir/drive.conf | sed "s/\[//g" | sed "s/\]//g")"
DRIVE_NAME_AUTO="$(sed -n '1p' /mnt/data/config/rclone.conf | sed "s/\[//g" | sed "s/\]//g")"
if [ "${DRIVE_NAME}" = "auto" ]; then
DRIVENAME=${DRIVE_NAME_AUTO}
else
Expand All @@ -13,7 +13,7 @@ elif [ "${POST_MODE}" = "move" ]; then
sed -i "s|MODE_STATUS|<br />Aria2 Event Hook:<br />[move] Move files to local finished folder after download completed</b>|g" /.aria2allinoneworkdir/homer/assets/config.yml
elif [ "${POST_MODE}" = "custom" ]; then
sed -i "s|MODE_STATUS|<br />Aria2 Event Hook: [custom]</b>|g" /.aria2allinoneworkdir/homer/assets/config.yml
elif [ ! -f "/.aria2allinoneworkdir/drive.conf" ]; then
elif [ ! -f "/mnt/data/config/rclone.conf" ]; then
sed -i "s|MODE_STATUS|<br />Aria2 Event Hook:<br />Fail to find Rclone config file</b>|g" /.aria2allinoneworkdir/homer/assets/config.yml
elif [ "${POST_MODE}" = "copy_remote" ]; then
sed -i "s|MODE_STATUS|<br />Aria2 Event Hook:<br />[copy_remote] Move files to local finished folder after both download and seeding completed, then copy to Rclone remote ${DRIVENAME}</b>|g" /.aria2allinoneworkdir/homer/assets/config.yml
Expand Down
4 changes: 3 additions & 1 deletion content/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh

VERSION="$(curl --retry 10 --retry-max-time 60 https://api.github.com/repos/iawia002/lux/releases/latest | jq .tag_name | sed 's/\"//g;s/v//g')"
curl -s --retry 10 --retry-max-time 60 -H "Cache-Control: no-cache" -fsSL github.com/iawia002/lux/releases/download/v${VERSION}/lux_${VERSION}_Linux_64-bit.tar.gz -o - | tar -zxf - -C /usr/bin
curl -s --retry 10 --retry-max-time 20 -H "Cache-Control: no-cache" -fsSL github.com/iawia002/lux/releases/download/v${VERSION}/lux_${VERSION}_Linux_64-bit.tar.gz -o - | tar -zxf - -C /usr/bin
mkdir -p /mnt/data/config /mnt/data/downloads /mnt/data/videos
echo ${RCLONE_CONFIG_BASE64} | base64 -d >/mnt/data/config/rclone.conf

exec runsvdir -P /etc/service
Loading

0 comments on commit b228554

Please sign in to comment.