diff --git a/Dockerfile b/Dockerfile index 7bf61ce..d9c0604 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,7 @@ ENV CADDYPATH=/app ENV RCLONE_CONFIG=/app/conf/rclone.conf ENV XDG_DATA_HOME=/app/.caddy/data ENV XDG_CONFIG_HOME=/app/.caddy/config +ENV RCLONE_CONFIG_BASE64="" ADD install.sh aria2c.sh caddy.sh Procfile init.sh start.sh rclone.sh /app/ ADD conf /app/conf diff --git a/README.CN.md b/README.CN.md index 158b407..8ccee2b 100644 --- a/README.CN.md +++ b/README.CN.md @@ -106,16 +106,16 @@ services: ### 支持的 Docker 环境变量 - * ENABLE_AUTH 启用 Basic auth(网页简单认证) 用户认证 - * ENABLE_RCLONE 是否启用 RCLONE,由于Rclone 的初次运行需要从Github 下载文件,由于你懂的原因,可能文件下载失败,进而导致整个程序崩溃,这时你需要设置为`false` - * ARIA2_USER Basic Auth 用户认证用户名,Rclone也使用该参数 - * ARIA2_PWD Basic Auth 密码,Rclone也使用该参数 - * ARIA2_EXTERNAL_PORT 从外部可以访问到的 Aria2 端口,默认为 HTTP 的`80` - * PUID 需要绑定主机的Linux用户ID,可以通过`cat /etc/passwd` 查看用户列表, 默认UID 是`1000` - * PGID 需要绑定的主机的Linux 用户组ID,默认GID 是`1000` - * RPC_SECRET Aria2 RPC 加密 token - * DOMAIN 绑定的域名, 当绑定的域名为`HTTPS`时,即为启用`HTTPS`, 例: `DOMAIN=https://toozhao.com` - + * `ENABLE_AUTH` 启用 Basic auth(网页简单认证) 用户认证 + * `ENABLE_RCLONE` 是否启用 RCLONE,由于Rclone 的初次运行需要从Github 下载文件,由于你懂的原因,可能文件下载失败,进而导致整个程序崩溃,这时你需要设置为`false` + * `ARIA2_USER` Basic Auth 用户认证用户名,Rclone也使用该参数 + * `ARIA2_PWD` Basic Auth 密码,Rclone也使用该参数 + * `ARIA2_EXTERNAL_PORT` 从外部可以访问到的 Aria2 端口,默认为 HTTP 的`80` + * `PUID` 需要绑定主机的Linux用户ID,可以通过`cat /etc/passwd` 查看用户列表, 默认UID 是`1000` + * `PGID` 需要绑定的主机的Linux 用户组ID,默认GID 是`1000` + * `RPC_SECRET` Aria2 RPC 加密 token + * `DOMAIN` 绑定的域名, 当绑定的域名为`HTTPS`时,即为启用`HTTPS`, 例: `DOMAIN=https://toozhao.com` + * `RCLONE_CONFIG_BASE64` 通过`base64` 字符串的形式配置rclone.conf。主要给在Heroku平台上运行时使用,请使用命令行 `cat /app/conf/rclone.conf | base64` 或者其他任何在线base64在线工具 [比如这个](https://www.base64encode.org/)来把`rclone.conf`的内容生成`base64`字符串。在使用本环境变量的同时,请确保`ENABLE_RCLONE`设置为`true`。 ### 支持的 Docker volume 属性 * `/data` 用来放置所有下载的文件的目录 diff --git a/README.md b/README.md index 8e93a3a..bc65897 100644 --- a/README.md +++ b/README.md @@ -117,15 +117,16 @@ Then simply run `docker-compose up -d`, that's it! ### Supported Environment Variables - * ENABLE_AUTH whether to enable Basic auth - * ENABLE_RCLONE whether to disable Rclone, if you running this container offline or do not have stable connection to Github, please set to `false` - * ARIA2_USER Basic Auth username, Rclone GUI uses it as well. - * ARIA2_PWD Basic Auth password, Rclone GUI uses it as well. - * ARIA2_EXTERNAL_PORT The Aria2 port which exposed to public to access to - * PUID Bind Linux UID into container which means you can use non `root` user to manage downloaded files, default UID is `1000` - * PGID Bind Linux GID into container, default GID is 1000 - * RPC_SECRET The Aria2 RPC secret token - * DOMAIN The domain you'd like to bind, when domain is a `https://` thing, then auto TLS feature will be enabled + * `ENABLE_AUTH` whether to enable Basic auth + * `ENABLE_RCLONE` whether to disable Rclone, if you running this container offline or do not have stable connection to Github, please set to `false` + * `ARIA2_USER` Basic Auth username, Rclone GUI uses it as well. + * `ARIA2_PWD` Basic Auth password, Rclone GUI uses it as well. + * `ARIA2_EXTERNAL_PORT` The Aria2 port which exposed to public to access to + * `PUID` Bind Linux UID into container which means you can use non `root` user to manage downloaded files, default UID is `1000` + * `PGID` Bind Linux GID into container, default GID is 1000 + * `RPC_SECRET` The Aria2 RPC secret token + * `DOMAIN` The domain you'd like to bind, when domain is a `https://` thing, then auto TLS feature will be enabled + * `RCLONE_CONFIG_BASE64` Inject and config Rclone through `base64` string, which is the only way to use Rclone on Heroku. Please use `cat /app/conf/rclone.conf | base64` or any base64 online tools such as [this](https://www.base64encode.org/) to encode your `rclone.conf` as bse64 string. Note, you need to set `ENABLE_RCLONE` to true as well. ### Supported Volumes diff --git a/app.json b/app.json index ce756d1..3fd1963 100644 --- a/app.json +++ b/app.json @@ -11,6 +11,11 @@ "value": "heroku", "required": false }, + "RCLONE_CONFIG_BASE64": { + "description": "This value is the base64 string of your preconfigured /app/conf/rclone.conf content", + "value": "", + "required": false + }, "ARIA2_USER": { "description": "Username to login to AriaNg", "value": "user", diff --git a/aria2c.sh b/aria2c.sh index cc86bb7..9be5217 100755 --- a/aria2c.sh +++ b/aria2c.sh @@ -5,7 +5,7 @@ RPC_SECRET_BASE64=$(echo -n ${RPC_SECRET}|base64) sed -i 's/secret:\"\"/secret:\"'"${RPC_SECRET_BASE64}"'\"/g' /usr/local/www/aria2/js/aria-ng*.js if [ "$ARIA2_SSL" = "true" ]; then -echo "Start aria2 with secure config" +echo "[INFO] Start aria2 with secure config" /usr/bin/aria2c --conf-path="/app/conf/aria2.conf" \ --enable-rpc --rpc-listen-all \ @@ -15,7 +15,7 @@ echo "Start aria2 with secure config" else -echo "Start aria2 with standard mode" +echo "[INFO] Start aria2 with standard mode" /usr/bin/aria2c --conf-path="/app/conf/aria2.conf" --enable-rpc --rpc-listen-all fi diff --git a/caddy.sh b/caddy.sh index 920ec8d..03f423e 100755 --- a/caddy.sh +++ b/caddy.sh @@ -1,20 +1,20 @@ #! /bin/bash -eu -echo "Run aria2c and ariaNG" +echo "[INFO] Run aria2c and ariaNG" -echo "**** Generate basic auth password for caddy ****" +echo "[INFO] Generate basic auth password for caddy" ARIA2_PWD_ENCRYPT=$(caddy hash-password -plaintext ${ARIA2_PWD}) case $ENABLE_AUTH in true) - echo "Using Basic Auth config file " + echo "[INFO] Use Basic Auth config file " export CADDY_FILE=/usr/local/caddy/SecureCaddyfile sed -i 's/ARIA2_USER/'"${ARIA2_USER}"'/g' ${CADDY_FILE} sed -i 's/ARIA2_PWD_ENCRYPT/'"${ARIA2_PWD_ENCRYPT}"'/g' ${CADDY_FILE} ;; heroku) - echo "Running in Heroku mode" + echo "[INFO] Run Caddy with Heroku mode" export CADDY_FILE=/usr/local/caddy/HerokuCaddyfile sed -i 's/ARIA2_USER/'"${ARIA2_USER}"'/g' ${CADDY_FILE} sed -i 's/ARIA2_PWD_ENCRYPT/'"${ARIA2_PWD_ENCRYPT}"'/g' ${CADDY_FILE} @@ -23,7 +23,7 @@ heroku) ;; *) - echo "Using caddy without Basic Auth" + echo "[INFO] Use caddy without Basic Auth" export CADDY_FILE=/usr/local/caddy/Caddyfile ;; esac diff --git a/init.sh b/init.sh index e46ecde..d56037a 100755 --- a/init.sh +++ b/init.sh @@ -1,6 +1,6 @@ #! /bin/bash -eu -echo "**** update uid and gid to ${PUID}:${PGID} ****" +echo "[INFO] Update uid and gid to ${PUID}:${PGID}" groupmod -o -g "$PGID" junv usermod -o -u "$PUID" junv @@ -19,7 +19,7 @@ chmod +x /app/caddy.sh \ /app/rclone.sh \ /app/aria2c.sh -echo "**** give caddy permissions to use low ports ****" +echo "[INFO] Give caddy permissions to use low ports" setcap cap_net_bind_service=+ep /usr/local/bin/caddy "${@-sh}" diff --git a/install.sh b/install.sh index 33f1b85..360a3be 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #! /bin/sh -eux -echo "Set variables for $(arch)" +echo "[INFO] Set variables for $(arch)" caddy_version=2.4.5 filebrowser_version=v2.17.2 @@ -30,7 +30,7 @@ case "$(arch)" in ;; *) - echo "unsupported arch $(arch), exit now" + echo "[ERROR] unsupported arch $(arch), exit now" exit 1 ;; esac @@ -40,7 +40,7 @@ ariang_file=AriaNg-${ariang_version}.zip adduser -D -u 1000 junv \ && apk update \ - && apk add runit shadow wget bash curl openrc gnupg aria2 tar mailcap --no-cache \ + && apk add runit shadow wget bash curl openrc gnupg aria2 tar mailcap fuse vim --no-cache \ && wget -N https://github.com/caddyserver/caddy/releases/download/v${caddy_version}/${caddy_file} \ && tar -zxf ${caddy_file} \ && mv caddy /usr/local/bin/ \ @@ -71,3 +71,5 @@ adduser -D -u 1000 junv \ && unzip ${ariang_file} \ && rm -rf ${ariang_file} \ && chmod -R 755 /usr/local/www/aria2 \ + && mkdir -p /data/cloud \ + && chown junv:junv /data/cloud diff --git a/rclone.sh b/rclone.sh index d0c8010..b234d51 100755 --- a/rclone.sh +++ b/rclone.sh @@ -1,7 +1,13 @@ #! /bin/bash -eu +if [ "$RCLONE_CONFIG_BASE64" != "" ]; then + echo "[INFO] Config Rclone from RCLONE_CONFIG_BASE64 env" + echo $RCLONE_CONFIG_BASE64 | base64 -d > /app/conf/rclone.conf + echo "[INFO] Config Rclone from RCLONE_CONFIG_BASE64 completed" +fi + if [ "$ENABLE_RCLONE" = "true" ]; then - echo "Start Rclone, please make sure you can connect to Github website. if not, please set docker env ENABLE_RCLONE=false" + echo "[INFO] Start Rclone, please make sure you can connect to Github website. if not, please set docker env ENABLE_RCLONE=false" rclone rcd --rc-web-gui \ --rc-web-gui-no-open-browser \ --rc-addr :5572 \ @@ -9,6 +15,6 @@ if [ "$ENABLE_RCLONE" = "true" ]; then --rc-pass $ARIA2_PWD \ --cache-dir /app/.cache else - echo "Skip starting Rclone as it's been disabled" + echo "[INFO] Skip starting Rclone as it has been disabled" sleep 3650d fi