Skip to content

Commit

Permalink
make tar1090 install / update more consistent
Browse files Browse the repository at this point in the history
use original tar1090 install script for most things
  • Loading branch information
wiedehopf committed Apr 22, 2023
1 parent 7d3963a commit 0b67aa3
Show file tree
Hide file tree
Showing 9 changed files with 494 additions and 162 deletions.
20 changes: 9 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
S6_SERVICES_GRACETIME=10000 \
S6_KILL_GRACETIME=10000 \
BEASTPORT=30005 \
GITPATH_TAR1090=/opt/tar1090 \
GITPATH_TAR1090_DB=/opt/tar1090-db \
GITPATH_TAR1090_AC_DB=/opt/tar1090-ac-db \
GITPATH_TIMELAPSE1090=/opt/timelapse1090 \
HTTP_ACCESS_LOG="false" \
HTTP_ERROR_LOG="true" \
Expand Down Expand Up @@ -63,15 +60,16 @@ RUN set -x && \
&& \
# nginx: remove default config
rm /etc/nginx/sites-enabled/default && \
# tar1090-db: clone
git clone --depth 1 https://github.com/wiedehopf/tar1090-db "${GITPATH_TAR1090_DB}" && \
# tar1090: install using project copy of original script
bash /tar1090-install.sh /run/readsb webroot "${TAR1090_INSTALL_DIR}" && \
# change some /run/tar1090-webroot to /run/readsb to make work with existing docker scripting
sed -i -e 's#/run/tar1090-webroot/#/run/readsb/#' /usr/local/share/tar1090/nginx-tar1090-webroot.conf && \
# tar1090-db: document version
pushd "${GITPATH_TAR1090_DB}" || exit 1 && \
pushd "${TAR1090_INSTALL_DIR}/git-db" || exit 1 && \
bash -ec 'echo "tar1090-db $(git log | head -1 | tr -s " " "_")" >> /VERSIONS' && \
popd && \
# tar1090: clone
git clone --single-branch --depth 1 "https://github.com/wiedehopf/tar1090.git" "${GITPATH_TAR1090}" && \
pushd "${GITPATH_TAR1090}" && \
# tar1090: document version
pushd "${TAR1090_INSTALL_DIR}/git" || exit 1 && \
bash -ec 'echo "tar1090 $(git log | head -1 | tr -s " " "_")" >> /VERSIONS' && \
popd && \
# tar1090: add nginx config
Expand All @@ -84,8 +82,8 @@ RUN set -x && \
popd && \
mkdir -p /var/timelapse1090 && \
# aircraft-db
mkdir -p "$GITPATH_TAR1090_AC_DB" && \
curl -o "$GITPATH_TAR1090_AC_DB/aircraft.csv.gz" "https://raw.githubusercontent.com/wiedehopf/tar1090-db/csv/aircraft.csv.gz" && \
curl -o "${TAR1090_INSTALL_DIR}/aircraft.csv.gz" "https://raw.githubusercontent.com/wiedehopf/tar1090-db/csv/aircraft.csv.gz" && \
git ls-remote https://github.com/wiedehopf/tar1090-db | grep refs/heads/csv > "${TAR1090_INSTALL_DIR}/aircraft.csv.gz.version" && \
# clone graphs1090 repo
git clone \
-b master \
Expand Down
41 changes: 12 additions & 29 deletions rootfs/etc/cont-init.d/02-tar1090-update
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,24 @@

source /scripts/common

cd "${GITPATH_TAR1090_DB}" || exit 1

if chk_enabled "${UPDATE_TAR1090}"; then
# Attempt to update tar1090 database
git fetch --depth 1 origin master > /dev/null 2>&1 || exit 0
git reset --hard origin/master > /dev/null 2>&1 || exit 0
if ! chk_enabled "${UPDATE_TAR1090}"; then
exit 0
fi

# Print tar1090 database version
DB_VERSION=$(git rev-parse --short HEAD)
echo "tar1090 database version: ${DB_VERSION}"
export DB_VERSION

cd "${GITPATH_TAR1090}" || exit 1

if chk_enabled "${UPDATE_TAR1090}"; then
# Attempt to update tar1090
git fetch origin master > /dev/null 2>&1 || exit 0
git reset --hard origin/master > /dev/null 2>&1 || exit 0

# get the aircraft db file
curl \
--silent \
--output /aircraft.csv.gz \
https://raw.githubusercontent.com/wiedehopf/tar1090-db/csv/aircraft.csv.gz || \
echo "Failed to download updated aircraft database. Using cached version"
bash /tar1090-install.sh /run/readsb webroot "${TAR1090_INSTALL_DIR}"

# copy new aircraft db file in to place
if [[ -e /aircraft.csv.gz ]]; then
rm -f "$GITPATH_TAR1090_AC_DB"/aircraft.csv.gz
mv /aircraft.csv.gz "$GITPATH_TAR1090_AC_DB"/aircraft.csv.gz
fi
# aircraft-db
if [[ "$TAR1090_ENABLE_AC_DB" == "true" ]]; then
git ls-remote https://github.com/wiedehopf/tar1090-db | grep refs/heads/csv > "/run/aircraft.csv.gz.version.new"
if ! diff "${TAR1090_INSTALL_DIR}/aircraft.csv.gz.version" "${TAR1090_INSTALL_DIR}/aircraft.csv.gz.version.new"; then
curl -o "${TAR1090_INSTALL_DIR}/aircraft.csv.gz" "https://raw.githubusercontent.com/wiedehopf/tar1090-db/csv/aircraft.csv.gz"
mv -f "/run/aircraft.csv.gz.version.new" "${TAR1090_INSTALL_DIR}/aircraft.csv.gz.version" || true
fi
fi

# Print tar1090 version
pushd "${TAR1090_INSTALL_DIR}/git" || exit 1
TAR1090_VERSION=$(git rev-parse --short HEAD)
echo "tar1090 version: ${TAR1090_VERSION}"
export TAR1090_VERSION
popd || exit 1
27 changes: 0 additions & 27 deletions rootfs/etc/cont-init.d/03-tar1090-copy

This file was deleted.

35 changes: 11 additions & 24 deletions rootfs/etc/cont-init.d/04-tar1090-configure
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,19 @@

source /scripts/common

# Modify nginx.conf
srcdir=/run/readsb
service=readsb
html_path=${TAR1090_INSTALL_DIR}/html
sed -i.original \
-e "s?SOURCE_DIR?$srcdir?g" \
-e "s?SERVICE?$service?g" \
-e "s?/INSTANCE/?/?g" \
-e "s?/INSTANCE?/?g" \
-e "s?HTMLPATH?$html_path?g" \
"${TAR1090_INSTALL_DIR}/nginx.conf"
sed -i '/location \/data\/ {/a \ \ access_log off;' \
"${TAR1090_INSTALL_DIR}/nginx.conf"

# Modify tar1090 settings
sed -i.original \
-e 's/skyview978/skyaware978/' \
"${TAR1090_INSTALL_DIR}/default"

# Add in CORS header for tar1090 data/aircraft.json file

sed -i 's/location ~ aircraft\\.json$ {/location ~ aircraft\.json$ {\n add_header Access-Control-Allow-Origin "\*";/g' \
"${TAR1090_INSTALL_DIR}/nginx.conf"
sed -i \
-e 's/location ~ aircraft\\.json$ {/location ~ aircraft\.json$ {\n add_header Access-Control-Allow-Origin "\*";/g' \
-e 's#/run/tar1090-webroot/#/run/readsb/#' \
"${TAR1090_INSTALL_DIR}/nginx-tar1090-webroot.conf"


# Wipe and configure tar1090 config.js.

rm -f "${TAR1090_INSTALL_DIR}/html-webroot/config.js"
cp "${TAR1090_INSTALL_DIR}/example_config.js" "${TAR1090_INSTALL_DIR}/html-webroot/config.js"

# Modify tar1090 config.js. tar1090's config.js file should be reset as part of
# /etc/cont-init.d/02-tar1090-update & /etc/cont-init.d/03-tar1090-copy
{

echo ""
Expand Down Expand Up @@ -164,4 +151,4 @@ if [[ -n "$TAR1090_ROUTEAPIURL" ]]; then
echo "routeApiUrl = ${TAR1090_ROUTEAPIURL};"
fi

} >> "${TAR1090_INSTALL_DIR}/html/config.js"
} >> "${TAR1090_INSTALL_DIR}/html-webroot/config.js"
68 changes: 0 additions & 68 deletions rootfs/etc/cont-init.d/05-tar1090-cachebust-and-gzip

This file was deleted.

2 changes: 1 addition & 1 deletion rootfs/etc/cont-init.d/06-range-outline
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if [ -n "${HEYWHATSTHAT_PANORAMA_ID}" ]; then

curl \
--silent \
--output /usr/local/share/tar1090/html/upintheair.json \
--output /usr/local/share/tar1090/html-webroot/upintheair.json \
"http://www.heywhatsthat.com/api/upintheair.json?id=${HEYWHATSTHAT_PANORAMA_ID}&refraction=0.25&alts=${HEYWHATSTHAT_ALTS:-12192}" || \
echo "WARNING: Unable to download panorama. Outline will not be available."; exit 0
fi
Expand Down
2 changes: 1 addition & 1 deletion rootfs/etc/cont-init.d/08-graphs1090
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ else
fi

# Finally, add a link to graphs1090 to the tar1090 web page:
sed -i 's|\(\s*\)\(<td id="dump1090_total_history_td"><span class="infoBlockTitleText">History:</span> <span id="dump1090_total_history">n/a</span> positions</td>\)|\1\2\n\1</tr>\n\1<tr class="infoblock_body"><td style="width: 50%"><span class="infoBlockTitleText">Stats available <a href="graphs1090/">here</a></td>|g' /usr/local/share/tar1090/html/index.html
sed -i 's|\(\s*\)\(<td id="dump1090_total_history_td"><span class="infoBlockTitleText">History:</span> <span id="dump1090_total_history">n/a</span> positions</td>\)|\1\2\n\1</tr>\n\1<tr class="infoblock_body"><td style="width: 50%"><span class="infoBlockTitleText">Stats available <a href="graphs1090/">here</a></td>|g' /usr/local/share/tar1090/html-webroot/index.html
2 changes: 1 addition & 1 deletion rootfs/etc/nginx.tar1090/sites-enabled/tar1090
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ server {
listen 80 default_server;
root /var/www/html;
server_name _;
include /usr/local/share/tar1090/nginx.conf;
include /usr/local/share/tar1090/nginx-tar1090-webroot.conf;

location /timelapse {
alias /opt/timelapse1090/html/;
Expand Down
Loading

0 comments on commit 0b67aa3

Please sign in to comment.