From 45597adcd3a916749308ad354c715b2169ea9ecf Mon Sep 17 00:00:00 2001 From: milkice Date: Mon, 29 Nov 2021 17:45:33 +0800 Subject: [PATCH] Integrate aria2c support & fix unintended behavior for docker image (#1073) * Update Dockerfile * Create docker-bootstrap.sh In addition to spawn cloudreve, this script generates password for aria2 so that users can take advantage of aria2 more conveniently instead of configuring aria2 by themselves. --- Dockerfile | 10 +++++++--- docker-bootstrap.sh | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 docker-bootstrap.sh diff --git a/Dockerfile b/Dockerfile index cbb7dca..9f92456 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,13 +46,17 @@ ARG TZ="Asia/Shanghai" ENV TZ ${TZ} COPY --from=be-builder /go/bin/Cloudreve /cloudreve/cloudreve +COPY docker-bootstrap.sh /cloudreve/bootstrap.sh RUN apk upgrade \ - && apk add bash tzdata \ + && apk add bash tzdata aria2 \ && ln -s /cloudreve/cloudreve /usr/bin/cloudreve \ && ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \ && echo ${TZ} > /etc/timezone \ - && rm -rf /var/cache/apk/* + && rm -rf /var/cache/apk/* \ + && mkdir /etc/cloudreve \ + && ln -s /etc/cloudreve/cloureve.db /cloudreve/cloudreve.db \ + && ln -s /etc/cloudreve/conf.ini /cloudreve/conf.ini # cloudreve use tcp 5212 port by default EXPOSE 5212/tcp @@ -65,4 +69,4 @@ VOLUME /etc/cloudreve VOLUME /data -ENTRYPOINT ["cloudreve"] +ENTRYPOINT ["sh", "/cloudreve/bootstrap.sh"] diff --git a/docker-bootstrap.sh b/docker-bootstrap.sh new file mode 100644 index 0000000..e5d86fb --- /dev/null +++ b/docker-bootstrap.sh @@ -0,0 +1,15 @@ +#!/bin/sh +GREEN='\033[0;32m' +RESET='\033[0m' +if [ ! -f /etc/cloudreve/aria2c.conf ]; then + echo -e "[${GREEN}aria2c${RESET}] aria2c config not found. Generating..." + secret=$(tr -dc A-Za-z0-9 /etc/cloudreve/aria2c.conf +enable-rpc=true +rpc-listen-port=6800 +rpc-secret=$secret +EOF +fi +aria2c --conf-path /etc/cloudreve/aria2c.conf -D +cloudreve