Compare commits

...

1 Commits

Author SHA1 Message Date
29bb822f5c testing 2024-09-11 23:41:17 -04:00
2 changed files with 21 additions and 6 deletions

View File

@ -22,7 +22,6 @@ RUN apt-get update && \
RUN curl -s -o "/tmp/libtorrent-${LIBTORRENT_VERSION}.tar.gz" -L "$LIBTORRENT_URL" && \ RUN curl -s -o "/tmp/libtorrent-${LIBTORRENT_VERSION}.tar.gz" -L "$LIBTORRENT_URL" && \
FILE_HASH="$(sha256sum /tmp/libtorrent-${LIBTORRENT_VERSION}.tar.gz | cut -d' ' -f1)" && \ FILE_HASH="$(sha256sum /tmp/libtorrent-${LIBTORRENT_VERSION}.tar.gz | cut -d' ' -f1)" && \
echo hey; \
du -sh "/tmp/libtorrent-${LIBTORRENT_VERSION}.tar.gz"; \ du -sh "/tmp/libtorrent-${LIBTORRENT_VERSION}.tar.gz"; \
if [ ! "$LIBTORRENT_HASH" = "$FILE_HASH" ]; then \ if [ ! "$LIBTORRENT_HASH" = "$FILE_HASH" ]; then \
echo "SHA256 verification failed!" && \ echo "SHA256 verification failed!" && \
@ -69,7 +68,9 @@ COPY --from=build /tmp/rtorrent.rc.template /tmp/rtorrent.rc.template
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y \ apt-get install -y \
libcurl4 \ libcurl4 \
libncursesw6 && \ libncursesw6 \
procps \
screen && \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
set -eu set -eux
# GID/UID # GID/UID
USER_ID=${GUID:-1000} USER_ID=${GUID:-1000}
@ -12,7 +12,7 @@ id -u rtorrent &>/dev/null || \
# Update group/user IDs # Update group/user IDs
groupmod -o -g "$GROUP_ID" rtorrent groupmod -o -g "$GROUP_ID" rtorrent
usermod -o -u "$USER_ID" rtorrent 2>/dev/null usermod -o -u "$USER_ID" rtorrent &>/dev/null
# Copy default config # Copy default config
if [ ! -e /home/rtorrent/.rtorrent.rc ]; then if [ ! -e /home/rtorrent/.rtorrent.rc ]; then
@ -20,5 +20,19 @@ if [ ! -e /home/rtorrent/.rtorrent.rc ]; then
chown rtorrent:rtorrent /home/rtorrent/.rtorrent.rc chown rtorrent:rtorrent /home/rtorrent/.rtorrent.rc
fi fi
# Execute as the rtorrent user # Trap for graceful shutdown
su - rtorrent -c "rtorrent" trap 'su - rtorrent -c "screen -S rtorrent -X stuff \"^Q\015\""; wait $SCREEN_PID' SIGTERM
# Start rtorrent in a detached screen session
su - rtorrent -c "screen -dmS rtorrent rtorrent" &
# Wait for the su process to finish
wait $!
# Find screen PID and monitor it
SCREEN_PID=$(pgrep -f "SCREEN -dmS rtorrent")
# Keep the script running until the screen session ends
tail --pid="$SCREEN_PID" -f /dev/null
exit 0