From a4eb149e869239929b541cd108fd4dc4b26ecd12 Mon Sep 17 00:00:00 2001 From: Aaron Shaw Date: Wed, 1 Jan 2025 19:02:54 +0000 Subject: [PATCH] feat: add tar1090 and graphs1090 displays - add tar1090 and graphs1090 using sdr-enthusiasts prebuilt container - add dockerfile modifications for running on balena - add start script for checks and setup Closes: #24 Closes: #41 --- docker-compose.yml | 31 +++++++++++++++++++--- tar1090/00-startup-checks | 51 +++++++++++++++++++++++++++++++++++++ tar1090/Dockerfile.template | 23 +++++++++++++++++ 3 files changed, 102 insertions(+), 3 deletions(-) create mode 100755 tar1090/00-startup-checks create mode 100644 tar1090/Dockerfile.template diff --git a/docker-compose.yml b/docker-compose.yml index f713f2c..ce974af 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,7 @@ version: '2.4' volumes: settings: radarbox: + tar1090: services: kiosk: restart: unless-stopped @@ -255,6 +256,33 @@ services: labels: io.balena.features.balena-api: '1' io.balena.features.supervisor-api: '1' + tar1090: + depends_on: + - dump1090-fa + - adsb-exchange + build: ./tar1090 + image: tar1090 + restart: unless-stopped + environment: + - BEASTHOST=dump1090-fa + - MLATHOST=adsb-exchange + - MLATPORT=30157 + - LAT= + - LON= + volumes: + - tar1090:/var/globe_history + - tar1090:/var/timelapse1090 + - tar1090:/var/lib/collectd + - tar1090:/var/lib/collectd/rrd + - tar1090:/var/log + ports: + - "8078:80" + labels: + - "io.balena.features.supervisor-api=1" + - "io.balena.features.procfs=1" + - "traefik.enable=true" + - "traefik.http.routers.tar1090.rule=PathPrefix(`/tar1090`)" + - "traefik.http.routers.tar1090-a.rule=PathPrefix(`/graphs1090`)" # Optional: Uncomment to enable custom mlat server. # mlat-client: # depends_on: @@ -269,6 +297,3 @@ services: # - MLAT_CLIENT_USER= # labels: # io.balena.features.supervisor-api: '1' - - - diff --git a/tar1090/00-startup-checks b/tar1090/00-startup-checks new file mode 100755 index 0000000..563d9dd --- /dev/null +++ b/tar1090/00-startup-checks @@ -0,0 +1,51 @@ +#!/command/with-contenv bash +# this ^ is a custom s6 helper for bringning in env variables +set -e + +# Bring in the common scripts from sdr-enthusiasts base image +source /scripts/common + +# Check if service has been disabled through the DISABLED_SERVICES environment variable. + +if [[ ",$(echo -e "${DISABLED_SERVICES}" | tr -d '[:space:]')," = *",$BALENA_SERVICE_NAME,"* ]]; then + echo "$BALENA_SERVICE_NAME is manually disabled. Sending request to stop the service:" + curl --header "Content-Type:application/json" "$BALENA_SUPERVISOR_ADDRESS/v2/applications/$BALENA_APP_ID/stop-service?apikey=$BALENA_SUPERVISOR_API_KEY" -d '{"serviceName": "'$BALENA_SERVICE_NAME'"}' + echo " " + sleep infinity +fi + +# Verify that all the required variables are set before starting up the application. + +echo "Verifying settings..." +echo " " +sleep 2 + +missing_variables=false + +# Begin defining all the required configuration variables. + +[ -z "$LAT" ] && echo "Receiver latitude is missing, will abort startup." && missing_variables=true || echo "Receiver latitude is set: $LAT" +[ -z "$LON" ] && echo "Receiver longitude is missing, will abort startup." && missing_variables=true || echo "Receiver longitude is set: $LON" + +if [ -z "${BEASTHOST}" ] && [ -z "${MLATHOST}" ] && [ -z "${READSB_DEVICE_TYPE}" ] && [ -z "${READSB_NET_CONNECTOR}" ] \ + && ! grep -qs -e 'adsb[^;]*_in' <<< "${ULTRAFEEDER_CONFIG}${ULTRAFEEDER_NET_CONNECTOR}"; then + echo -e "WARNING: No obvious data input configured: BEASTHOST / MLATHOST / READSB_NET_CONNECTOR / READSB_DEVICE_TYPE environment variables not set." + missing_variables=true +fi + +# End defining all the required configuration variables. + +echo " " + +if [ "$missing_variables" = true ] +then + echo "Settings missing, aborting..." + echo " " + sleep infinity +fi + +echo "Settings verified, proceeding with startup." +echo " " + +# We use LON for longitude but docker-tar1090 uses LONG +echo "$LON" > /var/run/s6/container_environment/LONG diff --git a/tar1090/Dockerfile.template b/tar1090/Dockerfile.template new file mode 100644 index 0000000..24ad341 --- /dev/null +++ b/tar1090/Dockerfile.template @@ -0,0 +1,23 @@ +FROM ghcr.io/sdr-enthusiasts/docker-tar1090:latest AS base +LABEL maintainer="https://github.com/ketilmo" + +COPY 00-startup-checks /etc/s6-overlay/startup.d + +RUN rm -f /etc/nginx/nginx-tar1090-webroot.conf && \ + wget -O /etc/nginx/nginx-tar1090.conf https://raw.githubusercontent.com/wiedehopf/tar1090/refs/heads/master/nginx.conf && \ + mv /usr/local/share/tar1090/html-webroot /usr/local/share/tar1090/html && \ + html_path=/usr/local/share/tar1090/html && \ + srcdir=/run/readsb && \ + service=tar1090 && \ + instance=tar1090 && \ + sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?${service}?g" \ + -e "s?INSTANCE?$instance?g" -e "s?HTMLPATH?$html_path?g" /etc/nginx/nginx-tar1090.conf && \ + sed -i -e 's/html-webroot/html/g' /etc/s6-overlay/startup.d/04-tar1090-configure && \ + sed -i -e 's?href="graphs1090/"?href="../graphs1090/"?g' /etc/s6-overlay/startup.d/04-tar1090-configure && \ + sed -i -e 's/html-webroot/html/g' /etc/s6-overlay/startup.d/06-range-outline && \ + sed -i -e 's/webroot/tar1090/g' /etc/s6-overlay/scripts/tar1090-update && \ + sed -i -e 's/nginx-tar1090-webroot/nginx-tar1090/g' /etc/nginx.tar1090/sites-enabled/tar1090 && \ + sed -i -e 's/nginx-tar1090-webroot/nginx-tar1090/g' /etc/nginx/sites-enabled/tar1090 && \ + sed -i -e 's/nginx-tar1090-webroot/nginx-tar1090/g' /etc/s6-overlay/startup.d/07-nginx-configure + +HEALTHCHECK NONE