From ff7a62fd9d13ae16ff4068ed58cc8aa2b49e6a16 Mon Sep 17 00:00:00 2001 From: DyonR Date: Tue, 2 Nov 2021 16:56:16 +0100 Subject: [PATCH 1/6] Switch to bullseye repo instead of buster --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6251301..29a1f36 100644 --- a/Dockerfile +++ b/Dockerfile @@ -193,7 +193,7 @@ RUN echo "deb http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.li /var/tmp/* # Install (un)compressing tools like unrar, 7z, unzip and zip -RUN echo "deb http://deb.debian.org/debian/ buster non-free" > /etc/apt/sources.list.d/non-free-unrar.list \ +RUN echo "deb http://deb.debian.org/debian/ bullseye non-free" > /etc/apt/sources.list.d/non-free-unrar.list \ && printf 'Package: *\nPin: release a=non-free\nPin-Priority: 150\n' > /etc/apt/preferences.d/limit-non-free \ && apt update \ && apt -y upgrade \ From 532255c816ddbb71798f25e04f0737bf5759d672 Mon Sep 17 00:00:00 2001 From: DyonR Date: Tue, 2 Nov 2021 17:08:42 +0100 Subject: [PATCH 2/6] Added prune to autoremove --- Dockerfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 29a1f36..074e39f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,8 @@ RUN mkdir -p /downloads /config/qBittorrent /etc/openvpn /etc/qbittorrent # Install boost RUN apt update \ - && apt -y upgrade \ - && apt -y install --no-install-recommends \ + && apt upgrade -y \ + && apt install -y --no-install-recommends \ curl \ ca-certificates \ g++ \ @@ -31,7 +31,7 @@ RUN apt update \ g++ \ libxml2-utils \ && apt-get clean \ - && apt -y autoremove \ + && apt autoremove -y --prune \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -58,7 +58,7 @@ RUN apt update \ jq \ unzip \ && apt-get clean \ - && apt autoremove -y \ + && apt autoremove -y --prune \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -82,7 +82,7 @@ RUN apt update \ curl \ jq \ && apt-get clean \ - && apt autoremove -y \ + && apt autoremove -y --prune \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -116,7 +116,7 @@ RUN apt update \ jq \ libssl-dev \ && apt-get clean \ - && apt autoremove -y \ + && apt autoremove -y --prune \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -158,7 +158,7 @@ RUN apt update \ qttools5-dev \ zlib1g-dev \ && apt-get clean \ - && apt autoremove -y \ + && apt autoremove -y --prune \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -186,7 +186,7 @@ RUN echo "deb http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.li procps \ wireguard-tools \ && apt-get clean \ - && apt autoremove -y \ + && apt autoremove -y --prune \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -203,7 +203,7 @@ RUN echo "deb http://deb.debian.org/debian/ bullseye non-free" > /etc/apt/source unzip \ zip \ && apt-get clean \ - && apt -y autoremove \ + && apt autoremove -y --prune \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ From 8afa7bcab8bc475f43424f986aab26dcc63673ae Mon Sep 17 00:00:00 2001 From: Rick Branson Date: Tue, 7 Dec 2021 16:33:27 -0800 Subject: [PATCH 3/6] Support graceful shutdowns of qbittorrent --- qbittorrent/start.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/qbittorrent/start.sh b/qbittorrent/start.sh index 453abc4..2ed602a 100644 --- a/qbittorrent/start.sh +++ b/qbittorrent/start.sh @@ -100,13 +100,22 @@ echo "[INFO] Starting qBittorrent daemon..." | ts '%Y-%m-%d %H:%M:%.S' /bin/bash /etc/qbittorrent/qbittorrent.init start & chmod -R 755 /config/qBittorrent -# Wait a second for it to start up and get the process id -sleep 1 -qbittorrentpid=$(pgrep -o -x qbittorrent-nox) -echo "[INFO] qBittorrent PID: $qbittorrentpid" | ts '%Y-%m-%d %H:%M:%.S' +# wait for the qbittorrent.init script to finish and grab the qbittorrent pid +# from the file created by the start script +wait $! +qbittorrentpid=$(cat /var/run/qbittorrent.pid) # If the process exists, make sure that the log file has the proper rights and start the health check if [ -e /proc/$qbittorrentpid ]; then + echo "[INFO] qBittorrent PID: $qbittorrentpid" | ts '%Y-%m-%d %H:%M:%.S' + + # trap the TERM signal for propagation and graceful shutdowns + handle_term() { + echo "[INFO] Received SIGTERM, stopping..." | ts '%Y-%m-%d %H:%M:%.S' + /bin/bash /etc/qbittorrent/qbittorrent.init stop + exit $? + } + trap handle_term SIGTERM if [[ -e /config/qBittorrent/data/logs/qbittorrent.log ]]; then chmod 775 /config/qBittorrent/data/logs/qbittorrent.log fi @@ -146,7 +155,9 @@ if [ -e /proc/$qbittorrentpid ]; then if [[ ! "${HEALTH_CHECK_SILENT}" == "1" || ! "${HEALTH_CHECK_SILENT}" == "true" || ! "${HEALTH_CHECK_SILENT}" == "yes" ]]; then echo "[INFO] Network is up" | ts '%Y-%m-%d %H:%M:%.S' fi - sleep ${INTERVAL} + sleep ${INTERVAL} & + # combine sleep background with wait so that the TERM trap above works + wait $! done else echo "[ERROR] qBittorrent failed to start!" | ts '%Y-%m-%d %H:%M:%.S' From e67d7d841fe532993903e27d0449fb6cc2a1f3a6 Mon Sep 17 00:00:00 2001 From: Badintral <79549469+Badintral@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:43:10 +0900 Subject: [PATCH 4/6] Apply chown only on files needing it --- qbittorrent/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qbittorrent/start.sh b/qbittorrent/start.sh index 453abc4..c5510ac 100644 --- a/qbittorrent/start.sh +++ b/qbittorrent/start.sh @@ -7,7 +7,7 @@ fi chown -R ${PUID}:${PGID} /config/qBittorrent # Set the rights on the /downloads folder -chown -R ${PUID}:${PGID} /downloads +find /downloads -not -user ${PUID} -execdir chown ${PUID}:${PGID} {} \+ # Check if qBittorrent.conf exists, if not, copy the template over if [ ! -e /config/qBittorrent/config/qBittorrent.conf ]; then From 663157da0ae49de4e15d3f1da68f606b521ec4bd Mon Sep 17 00:00:00 2001 From: brogers5 <6869577+brogers5@users.noreply.github.com> Date: Fri, 7 Jan 2022 22:10:48 -0500 Subject: [PATCH 5/6] Move initial iptables -V call to avoid nft initialization failure in legacy kernels. --- openvpn/start.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openvpn/start.sh b/openvpn/start.sh index 42a9032..40fddcb 100644 --- a/openvpn/start.sh +++ b/openvpn/start.sh @@ -22,17 +22,15 @@ else fi export LEGACY_IPTABLES=$(echo "${LEGACY_IPTABLES,,}") -iptables_version=$(iptables -V) -echo "[INFO] The container is currently running ${iptables_version}." | ts '%Y-%m-%d %H:%M:%.S' echo "[INFO] LEGACY_IPTABLES is set to '${LEGACY_IPTABLES}'" | ts '%Y-%m-%d %H:%M:%.S' if [[ $LEGACY_IPTABLES == "1" || $LEGACY_IPTABLES == "true" || $LEGACY_IPTABLES == "yes" ]]; then echo "[INFO] Setting iptables to iptables (legacy)" | ts '%Y-%m-%d %H:%M:%.S' update-alternatives --set iptables /usr/sbin/iptables-legacy - iptables_version=$(iptables -V) - echo "[INFO] The container is now running ${iptables_version}." | ts '%Y-%m-%d %H:%M:%.S' else echo "[INFO] Not making any changes to iptables version" | ts '%Y-%m-%d %H:%M:%.S' fi +iptables_version=$(iptables -V) +echo "[INFO] The container is currently running ${iptables_version}." | ts '%Y-%m-%d %H:%M:%.S' if [[ $VPN_ENABLED == "1" || $VPN_ENABLED == "true" || $VPN_ENABLED == "yes" ]]; then # Check if VPN_TYPE is set. From d26ea4bf6d559071f0744faa6fb2c2e40a5ef492 Mon Sep 17 00:00:00 2001 From: DyonR Date: Sun, 9 Jan 2022 00:18:12 +0100 Subject: [PATCH 6/6] Fix autoremove and fix HEALTH_CHECK_SILENT suppression Fixes and closes #82 --- Dockerfile | 14 +++++++------- qbittorrent/start.sh | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 074e39f..b2d3010 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ RUN apt update \ g++ \ libxml2-utils \ && apt-get clean \ - && apt autoremove -y --prune \ + && apt --purge autoremove -y \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -58,7 +58,7 @@ RUN apt update \ jq \ unzip \ && apt-get clean \ - && apt autoremove -y --prune \ + && apt --purge autoremove -y \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -82,7 +82,7 @@ RUN apt update \ curl \ jq \ && apt-get clean \ - && apt autoremove -y --prune \ + && apt --purge autoremove -y \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -116,7 +116,7 @@ RUN apt update \ jq \ libssl-dev \ && apt-get clean \ - && apt autoremove -y --prune \ + && apt --purge autoremove -y \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -158,7 +158,7 @@ RUN apt update \ qttools5-dev \ zlib1g-dev \ && apt-get clean \ - && apt autoremove -y --prune \ + && apt --purge autoremove -y \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -186,7 +186,7 @@ RUN echo "deb http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.li procps \ wireguard-tools \ && apt-get clean \ - && apt autoremove -y --prune \ + && apt --purge autoremove -y \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ @@ -203,7 +203,7 @@ RUN echo "deb http://deb.debian.org/debian/ bullseye non-free" > /etc/apt/source unzip \ zip \ && apt-get clean \ - && apt autoremove -y --prune \ + && apt --purge autoremove -y \ && rm -rf \ /var/lib/apt/lists/* \ /tmp/* \ diff --git a/qbittorrent/start.sh b/qbittorrent/start.sh index f1b46e9..5eee103 100644 --- a/qbittorrent/start.sh +++ b/qbittorrent/start.sh @@ -152,7 +152,7 @@ if [ -e /proc/$qbittorrentpid ]; then echo "[ERROR] Network is down, exiting this Docker" | ts '%Y-%m-%d %H:%M:%.S' exit 1 fi - if [[ ! "${HEALTH_CHECK_SILENT}" == "1" || ! "${HEALTH_CHECK_SILENT}" == "true" || ! "${HEALTH_CHECK_SILENT}" == "yes" ]]; then + if [ "${HEALTH_CHECK_SILENT}" == "0" ] || [ "${HEALTH_CHECK_SILENT}" == "false" ] || [ "${HEALTH_CHECK_SILENT}" == "no" ]; then echo "[INFO] Network is up" | ts '%Y-%m-%d %H:%M:%.S' fi sleep ${INTERVAL} &