Skip to content

Commit

Permalink
Add PF_HEATMAP parameter (#202)
Browse files Browse the repository at this point in the history
* Add PF_HEATMAP parameter

* Update planefence.conf

* Update planefence.sh

* Update planefence.config

* Update planefence

* Fix typo
  • Loading branch information
kx1t authored Jul 11, 2024
1 parent 43cc1de commit 8fd2bb2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
15 changes: 5 additions & 10 deletions rootfs/etc/s6-overlay/scripts/planefence
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/command/with-contenv bash
#shellcheck shell=bash

# redirect stderr to stdout so it's picked up in the docker logs
exec 2>&1
# all errors will show a line number and the command used to produce the error
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd)/$(basename "$0")"
trap 'echo -e "[ERROR] $SCRIPT_PATH in line $LINENO when executing: $BASH_COMMAND"' ERR
source /scripts/common

APPNAME="$(hostname)/planefence"
LOOPTIME=$(sed -n 's/\(^\s*PF_INTERVAL=\)\(.*\)/\2/p' /usr/share/planefence/persist/planefence.config)
[[ "$LOOPTIME" == "" ]] && LOOPTIME=60
PLANEFENCEDIR=/usr/share/planefence
Expand Down Expand Up @@ -55,11 +50,11 @@ do
[[ "$TIMING" != "" ]] && export BASETIME=$(date +%s.%2N) || unset BASETIME
$PLANEFENCEDIR/planefence.sh
endtime=$(date +%s)
[[ "$LOGLEVEL" != "ERROR" ]] && echo "[$APPNAME][$(date)] PlaneFence ran for $((endtime - starttime)) secs and will be running again at $(date -d @$(( $starttime + $LOOPTIME )) +"%Y/%m/%d %H:%M:%S")." || true
[[ "$LOGLEVEL" != "ERROR" ]] && "${s6wrap[@]}" echo "PlaneFence ran for $((endtime - starttime)) secs and will be running again at $(date -d @$(( $starttime + $LOOPTIME )) +"%Y/%m/%d %H:%M:%S")." || true
else
echo "[$APPNAME][$(date)] /run/socket30003/dump1090-*-(date +%y%m%d).txt not found."
echo "[$APPNAME][$(date)] If this continues to happen after 5-10 minutes, check this:"
echo "[$APPNAME][$(date)] Is \"socket30003\" running? Is your feeder producing data?"
"${s6wrap[@]}" echo "/run/socket30003/dump1090-*-(date +%y%m%d).txt not found."
"${s6wrap[@]}" echo "If this continues to happen after 5-10 minutes, check this:"
"${s6wrap[@]}" echo "Is \"socket30003\" running? Is your feeder producing data?"
fi
# [ -z "$TESTTIME" ] && LOOPTIME="$TESTTIME" # debug code
wait
Expand Down
3 changes: 2 additions & 1 deletion rootfs/usr/share/planefence/planefence.conf
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@

#
# PlaneHeat is an add-on that gets installed by default. It tracks a daily heatmap for planes that fly inside the
# PlaneFence coverage area. If you don't want to use it, comment out the parameter below.
# PlaneFence coverage area. If you don't want to use it, set PLANEHEAT=OFF.
# Normally, you don't need to update this parameter unless you moved 'planeheat.sh' to some other location,
# which we don't recommend doing unless you know which other files to move with it.

PLANEHEAT=ON
PLANEHEATSCRIPT=$PLANEFENCEDIR/planeheat.sh

#
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/planefence/planefence.sh
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ fi
[[ "$BASETIME" != "" ]] && echo "8. $(bc -l <<< "$(date +%s.%2N) - $BASETIME")s -- done invoking planefence_notify.sh, invoking PlaneHeat" || true

# And see if we need to run PLANEHEAT
if [ -f "$PLANEHEATSCRIPT" ] # && [ -f "$OUTFILECSV" ] <-- commented out to create heatmap even if there's no data
if chk_enabled "$PLANEHEAT" && [ -f "${PLANEHEATSCRIPT}" ] # && [ -f "$OUTFILECSV" ] <-- commented out to create heatmap even if there's no data
then
LOG "Invoking PlaneHeat!"
$PLANEHEATSCRIPT
Expand Down Expand Up @@ -1035,7 +1035,7 @@ EOF
fi

# if $PLANEHEATHTML exists, then add the heatmap
if [ -f "$PLANEHEATHTML" ]
if chk_enabled "$PLANEHEAT" && [ -f "$PLANEHEATHTML" ]
then
# shellcheck disable=SC2129
cat <<EOF >>"$OUTFILEHTMTMP"
Expand Down
4 changes: 3 additions & 1 deletion rootfs/usr/share/planefence/prep-planefence.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function configure_both() {
configure_planealert "$1" "$2"
}

[[ "$LOGLEVEL" != "ERROR" ]] && "${s6wrap[@]}" echo" Running PlaneFence configuration - either the container is restarted or a config change was detected." || true
[[ "$LOGLEVEL" != "ERROR" ]] && "${s6wrap[@]}" echo "Running PlaneFence configuration - either the container is restarted or a config change was detected." || true
# Sometimes, variables are passed in through .env in the Docker-compose directory
# However, if there is a planefence.config file in the ..../persist directory
# (by default exposed to ~/.planefence) then export all of those variables as well
Expand Down Expand Up @@ -232,6 +232,8 @@ fi

# -----------------------------------------------------------------------------------
#
# enable/disable planeheat;
chk_disabled "$PF_HEATMAP" && configure_planefence "PLANEHEAT" "OFF" || configure_planefence "PLANEHEAT" "ON"
# Change the heatmap height and width if they are defined in the .env parameter file:
[[ -n "$PF_MAPHEIGHT" ]] && sed -i 's|\(^\s*HEATMAPHEIGHT=\).*|\1'"\"$PF_MAPHEIGHT\""'|' /usr/share/planefence/planefence.conf
[[ -n "$PF_MAPWIDTH" ]] && sed -i 's|\(^\s*HEATMAPWIDTH=\).*|\1'"\"$PF_MAPWIDTH\""'|' /usr/share/planefence/planefence.conf
Expand Down
1 change: 1 addition & 0 deletions rootfs/usr/share/planefence/stage/planefence.config
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ PF_TRACKSVC=adsbexchange
# manually. To experiment with the OpenSteetMap zoom function, browse to this URL,
# move to your own location, zoom in/out and observe the "map=xx" value change in the URL bar:
# https://www.openstreetmap.org/#map=12/42.3763/-71.0604
PF_HEATMAP=enabled
PF_MAPHEIGHT=40vh
PF_MAPWIDTH=75vw
PF_MAPZOOM=7
Expand Down

0 comments on commit 8fd2bb2

Please sign in to comment.