From b532a7b58708159efb3b6388cd0b94828c6c9f08 Mon Sep 17 00:00:00 2001 From: Mmx233 <36563672+Mmx233@users.noreply.github.com> Date: Mon, 30 Dec 2024 18:02:52 +0800 Subject: [PATCH] improve(aria2): move aria2 data to /opt/aria2; fix permission issues References: https://github.com/AlistGo/with_aria2/pull/13 Co-authored-by: GoodbyeNJN --- Dockerfile | 14 +++++++++----- Dockerfile.ci | 14 +++++++++----- entrypoint.sh | 6 +++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 98265f9397d..f0d412487cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,12 +20,16 @@ RUN apk update && \ apk add --no-cache bash ca-certificates su-exec tzdata; \ [ "$INSTALL_FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \ [ "$INSTALL_ARIA2" = "true" ] && apk add --no-cache curl aria2 && \ - mkdir -p /root/.aria2 && \ + mkdir -p /opt/aria2/.aria2 && \ wget https://github.com/P3TERX/aria2.conf/archive/refs/heads/master.tar.gz -O /tmp/aria-conf.tar.gz && \ - tar -zxvf /tmp/aria-conf.tar.gz -C /root/.aria2 && rm -f /tmp/aria-conf.tar.gz && \ - sed -i 's|rpc-secret|#rpc-secret|g' /root/.aria2/aria2.conf && \ - touch /root/.aria2/aria2.session && \ - /root/.aria2/tracker.sh ; \ + tar -zxvf /tmp/aria-conf.tar.gz -C /opt/aria2/.aria2 && rm -f /tmp/aria-conf.tar.gz && \ + sed -i 's|rpc-secret|#rpc-secret|g' /opt/aria2/.aria2/aria2.conf && \ + sed -i 's|/root/.aria2|/opt/aria2/.aria2|g' /opt/aria2/.aria2/aria2.conf && \ + sed -i 's|/root/.aria2|/opt/aria2/.aria2|g' /opt/aria2/.aria2/script.conf && \ + sed -i 's|/root|/opt/aria2|g' /opt/aria2/.aria2/aria2.conf && \ + sed -i 's|/root|/opt/aria2|g' /opt/aria2/.aria2/script.conf && \ + touch /opt/aria2/.aria2/aria2.session && \ + /opt/aria2/.aria2/tracker.sh ; \ rm -rf /var/cache/apk/* COPY --from=builder /app/bin/alist ./ diff --git a/Dockerfile.ci b/Dockerfile.ci index 57e4936bbac..f3329ddbede 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -12,12 +12,16 @@ RUN apk update && \ apk add --no-cache bash ca-certificates su-exec tzdata; \ [ "$INSTALL_FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \ [ "$INSTALL_ARIA2" = "true" ] && apk add --no-cache curl aria2 && \ - mkdir -p /root/.aria2 && \ + mkdir -p /opt/aria2/.aria2 && \ wget https://github.com/P3TERX/aria2.conf/archive/refs/heads/master.tar.gz -O /tmp/aria-conf.tar.gz && \ - tar -zxvf /tmp/aria-conf.tar.gz -C /root/.aria2 && rm -f /tmp/aria-conf.tar.gz && \ - sed -i 's|rpc-secret|#rpc-secret|g' /root/.aria2/aria2.conf && \ - touch /root/.aria2/aria2.session && \ - /root/.aria2/tracker.sh ; \ + tar -zxvf /tmp/aria-conf.tar.gz -C /opt/aria2/.aria2 && rm -f /tmp/aria-conf.tar.gz && \ + sed -i 's|rpc-secret|#rpc-secret|g' /opt/aria2/.aria2/aria2.conf && \ + sed -i 's|/root/.aria2|/opt/aria2/.aria2|g' /opt/aria2/.aria2/aria2.conf && \ + sed -i 's|/root/.aria2|/opt/aria2/.aria2|g' /opt/aria2/.aria2/script.conf && \ + sed -i 's|/root|/opt/aria2|g' /opt/aria2/.aria2/aria2.conf && \ + sed -i 's|/root|/opt/aria2|g' /opt/aria2/.aria2/script.conf && \ + touch /opt/aria2/.aria2/aria2.session && \ + /opt/aria2/.aria2/tracker.sh ; \ rm -rf /var/cache/apk/* COPY /build/${TARGETPLATFORM}/alist ./ diff --git a/entrypoint.sh b/entrypoint.sh index 3932cb7a1b7..28a18d7d54c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,15 +5,15 @@ umask ${UMASK} if [ "$1" = "version" ]; then ./alist version else - chown -R ${PUID}:${PGID} /opt/alist/ - if [ "$RUN_ARIA2" = "true" ]; then + chown -R ${PUID}:${PGID} /opt/aria2/ exec su-exec ${PUID}:${PGID} nohup aria2c \ --enable-rpc \ --rpc-allow-origin-all \ - --conf-path=/root/.aria2/aria2.conf \ + --conf-path=/opt/aria2/.aria2/aria2.conf \ >/dev/null 2>&1 & fi + chown -R ${PUID}:${PGID} /opt/alist/ exec su-exec ${PUID}:${PGID} ./alist server --no-prefix fi \ No newline at end of file