Skip to content

Commit

Permalink
Fix for issue #4
Browse files Browse the repository at this point in the history
  • Loading branch information
mikenye committed May 6, 2020
1 parent 3b7237c commit 36a6d33
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ docker run -d \
-p 8078:80 \
-e TZ=<TIMEZONE> \
-e BEASTHOST=<BEASTHOST> \
-e LAT=xx.xxxxx \
-e LONG=xx.xxxxx \
mikenye/tar1090:latest
```

Expand All @@ -56,6 +58,8 @@ docker run -d \
-p 8078:80 \
-e TZ=Australia/Perth \
-e BEASTHOST=readsb \
-e LAT=-33.33333 \
-e LONG=111.11111 \
mikenye/tar1090:latest
```

Expand All @@ -81,6 +85,8 @@ services:
environment:
- TZ=Australia/Perth
- BEASTHOST=readsb
- LAT=-33.33333
- LONG=111.11111
networks:
- adsbnet
ports:
Expand Down Expand Up @@ -137,6 +143,8 @@ services:
environment:
- TZ=Australia/Perth
- BEASTHOST=readsb
- LAT=-33.33333
- LONG=111.11111
networks:
- adsbnet
ports:
Expand All @@ -161,6 +169,8 @@ This container accepts HTTP connections on TCP port `80` by default. You can cha
|----------------------|---------|---------|
| BEASTHOST | Required. IP/Hostname of a Mode-S/Beast provider (`dump1090`/`readsb`) | |
| BEASTPORT | Optional. TCP port number of Mode-S/Beast provider (`dump1090`/`readsb`) | `30005` |
| LAT | Optional. The latitude of your antenna | |
| LAT | Optional. The longitude of your antenna | |
| TZ | Optional. Your local timezone in [TZ-database-name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) format | |

## Logging
Expand Down
19 changes: 15 additions & 4 deletions rootfs/etc/cont-init.d/01-sanity-check
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
#!/usr/bin/with-contenv sh
# shellcheck shell=sh
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

# Define colours
YELLOW='\033[1;33m'
LIGHTRED='\033[1;31m'
NOCOLOR='\033[0m'

# Check to make sure the correct command line arguments have been set
EXITCODE=0
if [ -z "${BEASTHOST}" ]; then
echo "ERROR: BEASTHOST environment variable not set"
echo -e "${LIGHTRED}ERROR: BEASTHOST environment variable not set${NOCOLOR}"
EXITCODE=1
fi
if [ -z "${LAT}" ]; then
echo -e "${YELLOW}WARNING: LAT environment variable not set, Home location will not be accurate${NOCOLOR}"
fi
if [ -z "${LONG}" ]; then
echo -e "${YELLOW}WARNING: LONG environment variable not set, Home location will not be accurate${NOCOLOR}"
fi
if [ $EXITCODE -ne 0 ]; then
exit 1
fi

# Set up timezone
if [ -z "${TZ}" ]; then
echo "WARNING: TZ environment variable not set"
echo "${YELLOW}WARNING: TZ environment variable not set${NOCOLOR}"
else
ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" >/etc/timezone
fi
27 changes: 19 additions & 8 deletions rootfs/etc/services.d/readsb/run
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

exec \
/usr/local/bin/readsb \
--net-only \
--write-json=/run/readsb \
--quiet \
--stats-every=3600 \
--net-connector="${BEASTHOST}","${BEASTPORT}",beast_in \
2>&1 | awk -W interactive '{print "[readsb] " $0}'
# Build the readsb command line based on options
READSB_BIN="/usr/local/bin/readsb"

READSB_CMD=(--net-only)
READSB_CMD+=(--quiet)

if [ ! -z "${LAT}" ]; then
READSB_CMD+=(--lat "${LAT}")
fi

if [ ! -z "${LONG}" ]; then
READSB_CMD+=(--lon "${LONG}")
fi

READSB_CMD+=(--write-json=/run/readsb)
READSB_CMD+=(--stats-every=3600)
READSB_CMD+=(--net-connector="${BEASTHOST}","${BEASTPORT}",beast_in)

"${READSB_BIN}" "${READSB_CMD[@]}" 2>&1 | awk -W Interactive '{print "[readsb] " $0}'

0 comments on commit 36a6d33

Please sign in to comment.