Skip to content

Commit d4b8570

Browse files
authored
fix(docker): Fix the runsvdir permission issue caused by su-exec user switching and resolve the RUN_ARIA2 variable compatibility problem. (#805)
1 parent bd297e8 commit d4b8570

File tree

3 files changed

+33
-30
lines changed

3 files changed

+33
-30
lines changed

Dockerfile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@ RUN apk update && \
2828
sed -i 's|/root/.aria2|/opt/aria2/.aria2|g' /opt/aria2/.aria2/script.conf && \
2929
sed -i 's|/root|/opt/aria2|g' /opt/aria2/.aria2/aria2.conf && \
3030
sed -i 's|/root|/opt/aria2|g' /opt/aria2/.aria2/script.conf && \
31-
mkdir -p /opt/service/aria2/log && \
32-
echo '#!/bin/sh' > /opt/service/aria2/run && \
33-
echo 'exec 2>&1' >> /opt/service/aria2/run && \
34-
echo 'exec aria2c --enable-rpc --rpc-allow-origin-all --conf-path=/opt/aria2/.aria2/aria2.conf' >> /opt/service/aria2/run && \
35-
echo '#!/bin/sh' > /opt/service/aria2/log/run && \
36-
echo 'mkdir -p /opt/openlist/data/log/aria2 2>/dev/null' >> /opt/service/aria2/log/run && \
37-
echo 'exec svlogd /opt/openlist/data/log/aria2' >> /opt/service/aria2/log/run && \
38-
chmod +x /opt/service/aria2/run /opt/service/aria2/log/run && \
31+
mkdir -p /opt/service/stop/aria2/log && \
32+
echo '#!/bin/sh' > /opt/service/stop/aria2/run && \
33+
echo 'exec 2>&1' >> /opt/service/stop/aria2/run && \
34+
echo 'exec aria2c --enable-rpc --rpc-allow-origin-all --conf-path=/opt/aria2/.aria2/aria2.conf' >> /opt/service/stop/aria2/run && \
35+
echo '#!/bin/sh' > /opt/service/stop/aria2/log/run && \
36+
echo 'mkdir -p /opt/openlist/data/log/aria2 2>/dev/null' >> /opt/service/stop/aria2/log/run && \
37+
echo 'exec svlogd /opt/openlist/data/log/aria2' >> /opt/service/stop/aria2/log/run && \
38+
chmod +x /opt/service/stop/aria2/run /opt/service/stop/aria2/log/run && \
3939
touch /opt/aria2/.aria2/aria2.session && \
4040
/opt/aria2/.aria2/tracker.sh ; \
4141
rm -rf /var/cache/apk/*
4242

43-
RUN mkdir -p /opt/service/openlist && \
44-
echo '#!/bin/sh' > /opt/service/openlist/run && \
45-
echo 'exec 2>&1' >> /opt/service/openlist/run && \
46-
echo 'cd /opt/openlist' >> /opt/service/openlist/run && \
47-
echo 'exec ./openlist server --no-prefix' >> /opt/service/openlist/run && \
48-
chmod +x /opt/service/openlist/run
43+
RUN mkdir -p /opt/service/start/openlist && \
44+
echo '#!/bin/sh' > /opt/service/start/openlist/run && \
45+
echo 'exec 2>&1' >> /opt/service/start/openlist/run && \
46+
echo 'cd /opt/openlist' >> /opt/service/start/openlist/run && \
47+
echo 'exec ./openlist server --no-prefix' >> /opt/service/start/openlist/run && \
48+
chmod +x /opt/service/start/openlist/run
4949

5050
COPY --chmod=755 --from=builder /app/bin/openlist ./
5151
COPY --chmod=755 entrypoint.sh /entrypoint.sh

Dockerfile.ci

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ RUN apk update && \
2020
sed -i 's|/root/.aria2|/opt/aria2/.aria2|g' /opt/aria2/.aria2/script.conf && \
2121
sed -i 's|/root|/opt/aria2|g' /opt/aria2/.aria2/aria2.conf && \
2222
sed -i 's|/root|/opt/aria2|g' /opt/aria2/.aria2/script.conf && \
23-
mkdir -p /opt/service/aria2/log && \
24-
echo '#!/bin/sh' > /opt/service/aria2/run && \
25-
echo 'exec 2>&1' >> /opt/service/aria2/run && \
26-
echo 'exec aria2c --enable-rpc --rpc-allow-origin-all --conf-path=/opt/aria2/.aria2/aria2.conf' >> /opt/service/aria2/run && \
27-
echo '#!/bin/sh' > /opt/service/aria2/log/run && \
28-
echo 'mkdir -p /opt/openlist/data/log/aria2 2>/dev/null' >> /opt/service/aria2/log/run && \
29-
echo 'exec svlogd /opt/openlist/data/log/aria2' >> /opt/service/aria2/log/run && \
30-
chmod +x /opt/service/aria2/run /opt/service/aria2/log/run && \
23+
mkdir -p /opt/service/stop/aria2/log && \
24+
echo '#!/bin/sh' > /opt/service/stop/aria2/run && \
25+
echo 'exec 2>&1' >> /opt/service/stop/aria2/run && \
26+
echo 'exec aria2c --enable-rpc --rpc-allow-origin-all --conf-path=/opt/aria2/.aria2/aria2.conf' >> /opt/service/stop/aria2/run && \
27+
echo '#!/bin/sh' > /opt/service/stop/aria2/log/run && \
28+
echo 'mkdir -p /opt/openlist/data/log/aria2 2>/dev/null' >> /opt/service/stop/aria2/log/run && \
29+
echo 'exec svlogd /opt/openlist/data/log/aria2' >> /opt/service/stop/aria2/log/run && \
30+
chmod +x /opt/service/stop/aria2/run /opt/service/stop/aria2/log/run && \
3131
touch /opt/aria2/.aria2/aria2.session && \
3232
/opt/aria2/.aria2/tracker.sh ; \
3333
rm -rf /var/cache/apk/*
3434

35-
RUN mkdir -p /opt/service/openlist && \
36-
echo '#!/bin/sh' > /opt/service/openlist/run && \
37-
echo 'exec 2>&1' >> /opt/service/openlist/run && \
38-
echo 'cd /opt/openlist' >> /opt/service/openlist/run && \
39-
echo 'exec ./openlist server --no-prefix' >> /opt/service/openlist/run && \
40-
chmod +x /opt/service/openlist/run
35+
RUN mkdir -p /opt/service/start/openlist && \
36+
echo '#!/bin/sh' > /opt/service/start/openlist/run && \
37+
echo 'exec 2>&1' >> /opt/service/start/openlist/run && \
38+
echo 'cd /opt/openlist' >> /opt/service/start/openlist/run && \
39+
echo 'exec ./openlist server --no-prefix' >> /opt/service/start/openlist/run && \
40+
chmod +x /opt/service/start/openlist/run
4141

4242
COPY --chmod=755 /build/${TARGETPLATFORM}/openlist ./
4343
COPY --chmod=755 entrypoint.sh /entrypoint.sh

entrypoint.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ umask ${UMASK}
55
if [ "$1" = "version" ]; then
66
./openlist version
77
else
8+
if [ "$RUN_ARIA2" = "true" ]; then
9+
cp -a /opt/service/stop/aria2 /opt/service/start 2>/dev/null
10+
fi
811

9-
chown -R ${PUID}:${PGID} /opt/openlist/
10-
exec su-exec ${PUID}:${PGID} runsvdir /opt/service
12+
chown -R ${PUID}:${PGID} /opt
13+
exec su-exec ${PUID}:${PGID} runsvdir /opt/service/start
1114
fi

0 commit comments

Comments
 (0)