From a10d9854a7c60dbfe8513934064733e3a0f3c3b1 Mon Sep 17 00:00:00 2001 From: Metalcape Date: Thu, 9 Mar 2023 18:11:43 +0100 Subject: [PATCH 1/7] Install modified knockd from source --- build/alpine/install-packages.sh | 18 ++++++++++++++++-- build/ol/install-packages.sh | 16 +++++++++++++++- build/ubuntu/install-packages.sh | 20 +++++++++++++++++--- files/auto/autopause-daemon.sh | 2 +- files/auto/knockd-config.cfg | 1 + files/sudoers-mc | 2 +- 6 files changed, 51 insertions(+), 8 deletions(-) diff --git a/build/alpine/install-packages.sh b/build/alpine/install-packages.sh index fc2ffb8d384..c18322d4fb1 100755 --- a/build/alpine/install-packages.sh +++ b/build/alpine/install-packages.sh @@ -21,7 +21,21 @@ apk add --no-cache -U \ rsync \ nano \ sudo \ - knock \ tar \ zstd \ - nfs-utils \ No newline at end of file + nfs-utils \ + libpcap0.8 \ + libpcap-dev \ + autoconf \ + make \ + gcc + +# Install knockd from source + +git clone https://github.com/Metalcape/knock +cd knock +git checkout cooldown +autoreconf -fi +./configure --prefix=/usr/local +make +make install diff --git a/build/ol/install-packages.sh b/build/ol/install-packages.sh index e8eeadf8b10..948fc9be092 100755 --- a/build/ol/install-packages.sh +++ b/build/ol/install-packages.sh @@ -33,6 +33,20 @@ dnf install -y ImageMagick \ unzip \ zstd \ lbzip2 \ - knock + libpcap0.8 \ + libpcap-dev \ + autoconf \ + make \ + gcc bash /build/ol/install-gosu.sh + +# Install knockd from source + +git clone https://github.com/Metalcape/knock +cd knock +git checkout cooldown +autoreconf -fi +./configure --prefix=/usr/local +make +make install diff --git a/build/ubuntu/install-packages.sh b/build/ubuntu/install-packages.sh index f5ed4d01120..fa5e6e08f5c 100755 --- a/build/ubuntu/install-packages.sh +++ b/build/ubuntu/install-packages.sh @@ -23,7 +23,21 @@ apt-get install -y \ unzip \ zstd \ lbzip2 \ - knockd \ - nfs-common + nfs-common \ + libpcap0.8 \ + libpcap-dev \ + autoconf \ + make \ + gcc -apt-get clean \ No newline at end of file +apt-get clean + +# Install knockd from source + +git clone https://github.com/Metalcape/knock +cd knock +git checkout cooldown +autoreconf -fi +./configure --prefix=/usr/local +make +make install diff --git a/files/auto/autopause-daemon.sh b/files/auto/autopause-daemon.sh index 1cbfcdbed55..be884038293 100644 --- a/files/auto/autopause-daemon.sh +++ b/files/auto/autopause-daemon.sh @@ -45,7 +45,7 @@ if isTrue "${DEBUG_AUTOPAUSE}"; then knockdArgs+=(-D) fi -sudo /usr/sbin/knockd "${knockdArgs[@]}" +sudo /usr/local/sbin/knockd "${knockdArgs[@]}" if [ $? -ne 0 ] ; then logAutopause "Failed to start knockd daemon." logAutopause "Probable cause: Unable to attach to interface \"$AUTOPAUSE_KNOCK_INTERFACE\"." diff --git a/files/auto/knockd-config.cfg b/files/auto/knockd-config.cfg index 0334ad05132..1c54cc4896b 100644 --- a/files/auto/knockd-config.cfg +++ b/files/auto/knockd-config.cfg @@ -13,3 +13,4 @@ [unpauseMCServer-bedrock] sequence = 19132:udp command = /auto/resume.sh %IP% + seq_cooldown = 60 diff --git a/files/sudoers-mc b/files/sudoers-mc index 2869c23e128..bc0c19cda22 100644 --- a/files/sudoers-mc +++ b/files/sudoers-mc @@ -1,2 +1,2 @@ minecraft ALL=(ALL) NOPASSWD:/usr/bin/pkill -minecraft ALL=(ALL) NOPASSWD:/usr/sbin/knockd +minecraft ALL=(ALL) NOPASSWD:/usr/local/sbin/knockd From efab2ec96e26b77ee95b940d4d9e31426905293f Mon Sep 17 00:00:00 2001 From: Metalcape Date: Sat, 11 Mar 2023 21:27:15 +0100 Subject: [PATCH 2/7] Install knockd from binary --- Dockerfile | 5 +++++ build/alpine/install-packages.sh | 14 -------------- build/ol/install-packages.sh | 10 ---------- build/ubuntu/install-packages.sh | 14 -------------- 4 files changed, 5 insertions(+), 38 deletions(-) diff --git a/Dockerfile b/Dockerfile index a344cff7742..49f6f594c98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,6 +52,11 @@ RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \ | tar -C /usr/share -zxf - \ && ln -s /usr/share/mc-image-helper-${MC_HELPER_VERSION}/bin/mc-image-helper /usr/bin +# Install modified knockd +ADD https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-${TARGETARCH}.tar.gz /tmp/knock.tar.gz +RUN tar -xf /tmp/knock.tar.gz -C /usr/local/ && rm /tmp/knock.tar.gz +RUN find /usr/lib -name 'libpcap.so.0.8' -execdir cp '{}' libpcap.so.1 \; + VOLUME ["/data"] WORKDIR /data diff --git a/build/alpine/install-packages.sh b/build/alpine/install-packages.sh index c18322d4fb1..f46c33d2322 100755 --- a/build/alpine/install-packages.sh +++ b/build/alpine/install-packages.sh @@ -25,17 +25,3 @@ apk add --no-cache -U \ zstd \ nfs-utils \ libpcap0.8 \ - libpcap-dev \ - autoconf \ - make \ - gcc - -# Install knockd from source - -git clone https://github.com/Metalcape/knock -cd knock -git checkout cooldown -autoreconf -fi -./configure --prefix=/usr/local -make -make install diff --git a/build/ol/install-packages.sh b/build/ol/install-packages.sh index 948fc9be092..6700b6e279c 100755 --- a/build/ol/install-packages.sh +++ b/build/ol/install-packages.sh @@ -40,13 +40,3 @@ dnf install -y ImageMagick \ gcc bash /build/ol/install-gosu.sh - -# Install knockd from source - -git clone https://github.com/Metalcape/knock -cd knock -git checkout cooldown -autoreconf -fi -./configure --prefix=/usr/local -make -make install diff --git a/build/ubuntu/install-packages.sh b/build/ubuntu/install-packages.sh index fa5e6e08f5c..2ae39a2017d 100755 --- a/build/ubuntu/install-packages.sh +++ b/build/ubuntu/install-packages.sh @@ -25,19 +25,5 @@ apt-get install -y \ lbzip2 \ nfs-common \ libpcap0.8 \ - libpcap-dev \ - autoconf \ - make \ - gcc apt-get clean - -# Install knockd from source - -git clone https://github.com/Metalcape/knock -cd knock -git checkout cooldown -autoreconf -fi -./configure --prefix=/usr/local -make -make install From ef589b46b3c1408aa527f4d2d116cffacdbb9dad Mon Sep 17 00:00:00 2001 From: Metalcape Date: Sat, 11 Mar 2023 21:31:33 +0100 Subject: [PATCH 3/7] Use `TARGETARCH` and `TARGETVARIANT` for knockd --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 49f6f594c98..4d16cf9bcd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,7 +53,7 @@ RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \ && ln -s /usr/share/mc-image-helper-${MC_HELPER_VERSION}/bin/mc-image-helper /usr/bin # Install modified knockd -ADD https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-${TARGETARCH}.tar.gz /tmp/knock.tar.gz +ADD https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-${TARGETARCH}${TARGETVARIANT}.tar.gz /tmp/knock.tar.gz RUN tar -xf /tmp/knock.tar.gz -C /usr/local/ && rm /tmp/knock.tar.gz RUN find /usr/lib -name 'libpcap.so.0.8' -execdir cp '{}' libpcap.so.1 \; From 8ef5f3729844541a29ce6843389e975c0bb55dca Mon Sep 17 00:00:00 2001 From: Metalcape Date: Sat, 11 Mar 2023 21:32:18 +0100 Subject: [PATCH 4/7] Cleanup `install-packages.sh` --- build/ol/install-packages.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build/ol/install-packages.sh b/build/ol/install-packages.sh index 6700b6e279c..c3aeba34a4f 100755 --- a/build/ol/install-packages.sh +++ b/build/ol/install-packages.sh @@ -34,9 +34,5 @@ dnf install -y ImageMagick \ zstd \ lbzip2 \ libpcap0.8 \ - libpcap-dev \ - autoconf \ - make \ - gcc bash /build/ol/install-gosu.sh From 66152460a615eb58846e1f3c79755fe10e166382 Mon Sep 17 00:00:00 2001 From: Metalcape Date: Sat, 11 Mar 2023 23:33:24 +0100 Subject: [PATCH 5/7] Set cooldown to `AUTOPAUSE_TIMEOUT_KN/2` --- scripts/start-autopause | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/start-autopause b/scripts/start-autopause index 66fbbe60202..59d5c76bb03 100755 --- a/scripts/start-autopause +++ b/scripts/start-autopause @@ -84,4 +84,9 @@ elif [[ -z "$MAX_TICK_TIME" ]] ; then export MAX_TICK_TIME fi +# seq_cooldown cannot be larger than AUTOPAUSE_TIMEOUT_KN, otherwise the server may +# become paused while knockd is still ignoring packets, preventing players from joining. +let COOLDOWN=$AUTOPAUSE_TIMEOUT_KN/2 +sed -i "s/\(seq_cooldown *= *\).*/\1$COOLDOWN/" /tmp/knockd-config.cfg + /auto/autopause-daemon.sh & From 58ac11a827b09528b44ac77b00f86d3d43b6dc90 Mon Sep 17 00:00:00 2001 From: Metalcape Date: Sun, 12 Mar 2023 09:38:17 +0100 Subject: [PATCH 6/7] Fix install packages --- build/alpine/install-packages.sh | 2 +- build/ol/install-packages.sh | 2 +- build/ubuntu/install-packages.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/alpine/install-packages.sh b/build/alpine/install-packages.sh index f46c33d2322..4c116915e29 100755 --- a/build/alpine/install-packages.sh +++ b/build/alpine/install-packages.sh @@ -24,4 +24,4 @@ apk add --no-cache -U \ tar \ zstd \ nfs-utils \ - libpcap0.8 \ + libpcap diff --git a/build/ol/install-packages.sh b/build/ol/install-packages.sh index c3aeba34a4f..2f7cc3166d9 100755 --- a/build/ol/install-packages.sh +++ b/build/ol/install-packages.sh @@ -33,6 +33,6 @@ dnf install -y ImageMagick \ unzip \ zstd \ lbzip2 \ - libpcap0.8 \ + libpcap0.8 bash /build/ol/install-gosu.sh diff --git a/build/ubuntu/install-packages.sh b/build/ubuntu/install-packages.sh index 2ae39a2017d..d7b882258e7 100755 --- a/build/ubuntu/install-packages.sh +++ b/build/ubuntu/install-packages.sh @@ -24,6 +24,6 @@ apt-get install -y \ zstd \ lbzip2 \ nfs-common \ - libpcap0.8 \ + libpcap0.8 apt-get clean From 155a8fdd4ba1763186575d2c39bf58723c2e5013 Mon Sep 17 00:00:00 2001 From: Metalcape Date: Sun, 12 Mar 2023 16:00:29 +0100 Subject: [PATCH 7/7] Fix libpcap package for dnf --- build/ol/install-packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/ol/install-packages.sh b/build/ol/install-packages.sh index 2f7cc3166d9..eab5e562262 100755 --- a/build/ol/install-packages.sh +++ b/build/ol/install-packages.sh @@ -33,6 +33,6 @@ dnf install -y ImageMagick \ unzip \ zstd \ lbzip2 \ - libpcap0.8 + libpcap bash /build/ol/install-gosu.sh