From 7794f537585d26066b1bd6e9a773a2fb523149f6 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Wed, 17 Apr 2024 00:57:45 +0200 Subject: [PATCH 1/5] pfclient_daemon: replace mawk pipe with s6wrap prepend exec as well for nicer exits --- rootfs/etc/s6-overlay/scripts/pfclient | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/pfclient b/rootfs/etc/s6-overlay/scripts/pfclient index efa32de..64ddd12 100755 --- a/rootfs/etc/s6-overlay/scripts/pfclient +++ b/rootfs/etc/s6-overlay/scripts/pfclient @@ -4,7 +4,9 @@ # Test pfclient can run natively (without qemu) if /usr/local/bin/pfclient --version > /dev/null 2>&1; then # pfclient can be run natively - s6-setuidgid nobody /usr/local/bin/pfclient \ + exec s6-setuidgid nobody \ + s6wrap --quiet --prepend='pfclient_daemon' --args \ + /usr/local/bin/pfclient \ --connection_type=1 \ --address="${BEASTHOST}" \ --port="${BEASTPORT}" \ @@ -14,12 +16,13 @@ if /usr/local/bin/pfclient --version > /dev/null 2>&1; then --lon="${LONG}" \ --pid_file=/run/pfclient.pid \ --config_path=/config/pfclient-config.json \ - --log_path=/var/log/pfclient \ - 2>&1 | mawk -W Interactive '{print "[pfclient_daemon] " $0}' + --log_path=/var/log/pfclient else # pfclient needs qemu - s6-setuidgid nobody qemu-arm-static /usr/local/bin/pfclient \ + exec s6-setuidgid nobody \ + s6wrap --quiet --prepend='pfclient_daemon' --args \ + qemu-arm-static /usr/local/bin/pfclient \ --connection_type=1 \ --address="${BEASTHOST}" \ --port="${BEASTPORT}" \ @@ -29,6 +32,5 @@ else --lon="${LONG}" \ --pid_file=/run/pfclient.pid \ --config_path=/config/pfclient-config.json \ - --log_path=/var/log/pfclient \ - 2>&1 | mawk -W Interactive '{print "[pfclient_daemon] " $0}' + --log_path=/var/log/pfclient fi From 4bbd1c03152eab8f6396c7a3043abb146acf6e56 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Fri, 13 Sep 2024 17:20:06 +0200 Subject: [PATCH 2/5] remove qemu: no longer needed --- Dockerfile | 32 ++++++++++-------- rootfs/etc/s6-overlay/scripts/pfclient | 46 ++++++++------------------ rootfs/firstrun | 5 ++- 3 files changed, 33 insertions(+), 50 deletions(-) diff --git a/Dockerfile b/Dockerfile index d3c21eb..5ebbf5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM ghcr.io/sdr-enthusiasts/docker-baseimage:qemu +FROM ghcr.io/sdr-enthusiasts/docker-baseimage:base + +ARG TARGETPLATFORM TARGETOS TARGETARCH ENV BEASTPORT=30005 \ S6_BEHAVIOUR_IF_STAGE2_FAILS=2 @@ -9,18 +11,24 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] # hadolint ignore=DL3008,SC2086,SC2039,SC2068 RUN set -x && \ - dpkg --add-architecture armhf && \ TEMP_PACKAGES=() && \ KEPT_PACKAGES=() && \ # Deps for healthchecks - TEMP_PACKAGES+=(git) && \ KEPT_PACKAGES+=(jq) && \ KEPT_PACKAGES+=(net-tools) && \ KEPT_PACKAGES+=(procps) && \ # Deps for pfclient KEPT_PACKAGES+=(ca-certificates) && \ - KEPT_PACKAGES+=(libc6:armhf) && \ - #KEPT_PACKAGES+=(lsb-base:armhf) && \ + if [[ "${TARGETARCH}" == "arm64" ]]; then \ + DOWNLOAD_URL="http://client.planefinder.net/pfclient_5.1.440_arm64.tar.gz"; \ + DOWNLOAD_MD5SUM=fcba2b587d27442dddf5f18575222ca0; \ + elif [[ "${TARGETARCH}" == "amd64" ]]; then \ + DOWNLOAD_URL="http://client.planefinder.net/pfclient_5.0.162_amd64.tar.gz"; \ + DOWNLOAD_MD5SUM=3bb9734b43e665b16a5a9ef4c43bfed3; \ + else \ + DOWNLOAD_URL="http://client.planefinder.net/pfclient_5.0.161_armhf.tar.gz"; \ + DOWNLOAD_MD5SUM=0f1e6b90f292833060020d039b8d2fb1; \ + fi && \ # pfclient install & healthchecks KEPT_PACKAGES+=(curl) && \ # Install packages @@ -33,10 +41,10 @@ RUN set -x && \ curl \ --location \ --output "/tmp/pfclient.tar.gz" \ - "http://client.planefinder.net/pfclient_5.0.161_armhf.tar.gz" \ + "${DOWNLOAD_URL}" \ && \ # Check md5sum - echo "0f1e6b90f292833060020d039b8d2fb1 /tmp/pfclient.tar.gz" > /tmp/pfclient.md5sum && \ + echo "${DOWNLOAD_MD5SUM} /tmp/pfclient.tar.gz" > /tmp/pfclient.md5sum && \ md5sum --check /tmp/pfclient.md5sum && \ # Extract pfclient tar \ @@ -45,15 +53,11 @@ RUN set -x && \ && \ # Clean up apt-get remove -y ${TEMP_PACKAGES[@]} && \ - apt-get autoremove -y && \ + apt-get autoremove -q -o APT::Autoremove::RecommendsImportant=0 -o APT::Autoremove::SuggestsImportant=0 -y && \ apt-get clean -y && \ - rm -rf /var/lib/apt/lists/* /src /tmp/* && \ + rm -rf /src /tmp/* /var/lib/apt/lists/* /git /var/cache/* && \ # Document version - if /usr/local/bin/pfclient --version > /dev/null 2>&1; \ - then echo "pfclient $(/usr/local/bin/pfclient --version | head -1 | rev | cut -d " " -f 1 | rev)" >> /VERSION; \ - else echo "pfclient $(qemu-arm-static /usr/local/bin/pfclient --version | head -1 | rev | cut -d " " -f 1 | rev)" >> /VERSION; \ - fi \ - && \ + echo "pfclient $(/usr/local/bin/pfclient --version | head -1 | rev | cut -d " " -f 1 | rev)" >> /VERSION && \ grep 'pfclient' /VERSION | cut -d ' ' -f2- > /CONTAINER_VERSION && \ cat /CONTAINER_VERSION diff --git a/rootfs/etc/s6-overlay/scripts/pfclient b/rootfs/etc/s6-overlay/scripts/pfclient index 64ddd12..6c64343 100755 --- a/rootfs/etc/s6-overlay/scripts/pfclient +++ b/rootfs/etc/s6-overlay/scripts/pfclient @@ -1,36 +1,16 @@ #!/command/with-contenv bash #shellcheck shell=bash -# Test pfclient can run natively (without qemu) -if /usr/local/bin/pfclient --version > /dev/null 2>&1; then - # pfclient can be run natively - exec s6-setuidgid nobody \ - s6wrap --quiet --prepend='pfclient_daemon' --args \ - /usr/local/bin/pfclient \ - --connection_type=1 \ - --address="${BEASTHOST}" \ - --port="${BEASTPORT}" \ - --data_format=1 \ - --sharecode="${SHARECODE}" \ - --lat="${LAT}" \ - --lon="${LONG}" \ - --pid_file=/run/pfclient.pid \ - --config_path=/config/pfclient-config.json \ - --log_path=/var/log/pfclient - -else - # pfclient needs qemu - exec s6-setuidgid nobody \ - s6wrap --quiet --prepend='pfclient_daemon' --args \ - qemu-arm-static /usr/local/bin/pfclient \ - --connection_type=1 \ - --address="${BEASTHOST}" \ - --port="${BEASTPORT}" \ - --data_format=1 \ - --sharecode="${SHARECODE}" \ - --lat="${LAT}" \ - --lon="${LONG}" \ - --pid_file=/run/pfclient.pid \ - --config_path=/config/pfclient-config.json \ - --log_path=/var/log/pfclient -fi +exec s6-setuidgid nobody \ +s6wrap --quiet --prepend='pfclient_daemon' --args \ +/usr/local/bin/pfclient \ + --connection_type=1 \ + --address="${BEASTHOST}" \ + --port="${BEASTPORT}" \ + --data_format=1 \ + --sharecode="${SHARECODE}" \ + --lat="${LAT}" \ + --lon="${LONG}" \ + --pid_file=/run/pfclient.pid \ + --config_path=/config/pfclient-config.json \ + --log_path=/var/log/pfclient diff --git a/rootfs/firstrun b/rootfs/firstrun index 8780a0d..e108e0e 100755 --- a/rootfs/firstrun +++ b/rootfs/firstrun @@ -7,7 +7,6 @@ if /usr/local/bin/pfclient --version > /dev/null 2>&1; then s6-setuidgid nobody /usr/local/bin/pfclient else - # pfclient needs qemu - s6-setuidgid nobody qemu-arm-static /usr/local/bin/pfclient - + # pfclient isn't working + echo "ERROR, pfclient binary not working" fi From 7ca34bd5eeace316b93659839dfe8d04999bfc17 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Fri, 13 Sep 2024 17:25:49 +0200 Subject: [PATCH 3/5] logwatcher: don't hide truncation exec tail --- rootfs/etc/s6-overlay/scripts/logwatcher | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/etc/s6-overlay/scripts/logwatcher b/rootfs/etc/s6-overlay/scripts/logwatcher index 438a31e..0af4dbb 100755 --- a/rootfs/etc/s6-overlay/scripts/logwatcher +++ b/rootfs/etc/s6-overlay/scripts/logwatcher @@ -2,4 +2,4 @@ #shellcheck shell=bash sleep 5 -tail -c 100k -F /var/log/pfclient/*.log 2> >(grep -v truncated >&2) +exec tail -c 100k -F /var/log/pfclient/*.log From 87dd8de7c291c8bc61bed5801371b394087678eb Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Fri, 13 Sep 2024 18:04:13 +0200 Subject: [PATCH 4/5] suppress the delayed direct output of pfclient --- rootfs/etc/s6-overlay/scripts/logwatcher | 7 +++++-- rootfs/etc/s6-overlay/scripts/pfclient | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/logwatcher b/rootfs/etc/s6-overlay/scripts/logwatcher index 0af4dbb..2dfed12 100755 --- a/rootfs/etc/s6-overlay/scripts/logwatcher +++ b/rootfs/etc/s6-overlay/scripts/logwatcher @@ -1,5 +1,8 @@ #!/command/with-contenv bash #shellcheck shell=bash -sleep 5 -exec tail -c 100k -F /var/log/pfclient/*.log +while ! pgrep pfclient &>/dev/null; do + sleep 0.5 +done +exec s6wrap --timestamps --quiet --prepend='pfclient_log' --args \ + tail -c 100k -F /var/log/pfclient/*.log diff --git a/rootfs/etc/s6-overlay/scripts/pfclient b/rootfs/etc/s6-overlay/scripts/pfclient index 6c64343..328994a 100755 --- a/rootfs/etc/s6-overlay/scripts/pfclient +++ b/rootfs/etc/s6-overlay/scripts/pfclient @@ -2,7 +2,7 @@ #shellcheck shell=bash exec s6-setuidgid nobody \ -s6wrap --quiet --prepend='pfclient_daemon' --args \ +s6wrap --ignore=stdout --quiet --prepend='pfclient_daemon' --args \ /usr/local/bin/pfclient \ --connection_type=1 \ --address="${BEASTHOST}" \ From d614459100869520798e9c9d52d8412079d94dfc Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Fri, 13 Sep 2024 18:36:02 +0200 Subject: [PATCH 5/5] remove i386 from tests --- .github/workflows/tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c15bde1..c7cc0ba 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,6 @@ jobs: - linux/amd64 - linux/arm64 - linux/arm/v7 - - linux/i386 steps: # Check out our code - name: Checkout