Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
feat: add confd for config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Maugin authored and Thomas Maugin committed Mar 6, 2020
1 parent 1be9697 commit 93ad6ad
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ RUN mkdir -p /etc/modprobe.d && \
RUN mkdir -p /usr/lib/fr24/public_html/data
COPY --from=dump1090 /tmp/dump1090/dump1090 /usr/lib/fr24/
COPY --from=dump1090 /tmp/dump1090/public_html /usr/lib/fr24/public_html
RUN rm /usr/lib/fr24/public_html/config.js

# PIAWARE
COPY --from=piaware /tmp/piaware_builder /tmp/piaware_builder
Expand Down
6 changes: 6 additions & 0 deletions root/etc/confd/html/conf.d/html.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[template]
src = "config.js.tmpl"
dest = "/usr/lib/fr24/public_html/config.js"
keys = [
"/"
]
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ DisplayUnits = "nautical";
// degrees.

// Default center of the map.
DefaultCenterLat = 45.0;
DefaultCenterLon = 9.0;
DefaultCenterLat = {{getv "/site/lat"}};
DefaultCenterLon = {{getv "/site/lon"}};
// The google maps zoom level, 0 - 16, lower is further out
DefaultZoomLvl = 7;

// Center marker. If dump1090 provides a receiver location,
// that location is used and these settings are ignored.

SiteShow = false; // true to show a center marker
SiteLat = 45.0; // position of the marker
SiteLon = 9.0;
SiteName = "My Radar Site"; // tooltip of the marker
SiteLat = {{getv "/site/lat"}}; // position of the marker
SiteLon = {{getv "/site/lon"}};
SiteName = "{{getv "/site/name"}}"; // tooltip of the marker

// -- Marker settings -------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion root/etc/cont-init.d/01-confd-fr24feed
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_value()
key=${1//\-/_DASH_}
key=FR24FEED_${key^^}
eval "value=\${$key:-\$2}"
printf -v $key $value
printf -v $key "$value"
export $key
}

Expand Down
2 changes: 1 addition & 1 deletion root/etc/cont-init.d/02-confd-piaware
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_value()
key=${1//\-/_DASH_}
key=PIAWARE_${key^^}
eval "value=\${$key:-\$2}"
printf -v $key $value
printf -v $key "$value"
export $key
}

Expand Down
18 changes: 18 additions & 0 deletions root/etc/cont-init.d/03-confd-html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/with-contenv bash

default_value()
{
key=${1//\-/_DASH_}
key=HTML_${key^^}
eval "value=\${$key:-\$2}"
printf -v $key "$value"
export $key
}

default_value "site_lat" "45.0"
default_value "site_lon" "9.0"
default_value "site_name" "My Radar Site"

if [ ! -f /usr/lib/fr24/public_html/config.js ]; then
/opt/confd/bin/confd -onetime -confdir "/etc/confd/html" -prefix "html" -backend env
fi

0 comments on commit 93ad6ad

Please sign in to comment.