Skip to content

Commit

Permalink
feat: add tar1090 and graphs1090 displays
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
shawaj committed Jan 6, 2025
1 parent 98c3ec0 commit a4eb149
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 3 deletions.
31 changes: 28 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '2.4'
volumes:
settings:
radarbox:
tar1090:
services:
kiosk:
restart: unless-stopped
Expand Down Expand Up @@ -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:
Expand All @@ -269,6 +297,3 @@ services:
# - MLAT_CLIENT_USER=
# labels:
# io.balena.features.supervisor-api: '1'



51 changes: 51 additions & 0 deletions tar1090/00-startup-checks
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions tar1090/Dockerfile.template
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a4eb149

Please sign in to comment.