Skip to content

Commit

Permalink
remove qemu / cleanup (#76)
Browse files Browse the repository at this point in the history
* pfclient_daemon: replace mawk pipe with s6wrap prepend

exec as well for nicer exits

* remove qemu: no longer needed

* logwatcher: don't hide truncation

exec tail

* suppress the delayed direct output of pfclient

* remove i386 from tests
  • Loading branch information
wiedehopf authored Sep 13, 2024
1 parent 2b1da71 commit 1258189
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 51 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
- linux/amd64
- linux/arm64
- linux/arm/v7
- linux/i386
steps:
# Check out our code
- name: Checkout
Expand Down
32 changes: 18 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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 \
Expand All @@ -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

Expand Down
7 changes: 5 additions & 2 deletions rootfs/etc/s6-overlay/scripts/logwatcher
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/command/with-contenv bash
#shellcheck shell=bash

sleep 5
tail -c 100k -F /var/log/pfclient/*.log 2> >(grep -v truncated >&2)
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
44 changes: 13 additions & 31 deletions rootfs/etc/s6-overlay/scripts/pfclient
Original file line number Diff line number Diff line change
@@ -1,34 +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
s6-setuidgid nobody /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 \
2>&1 | mawk -W Interactive '{print "[pfclient_daemon] " $0}'

else
# pfclient needs qemu
s6-setuidgid nobody 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 \
2>&1 | mawk -W Interactive '{print "[pfclient_daemon] " $0}'
fi
exec s6-setuidgid nobody \
s6wrap --ignore=stdout --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
5 changes: 2 additions & 3 deletions rootfs/firstrun
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1258189

Please sign in to comment.