1
0
Fork 0
mirror of https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git synced 2024-12-29 07:42:00 +00:00
docker-adsb-ultrafeeder/rootfs/etc/services.d/autogain/run

43 lines
2 KiB
Text
Raw Normal View History

2023-03-24 12:44:41 +00:00
#!/usr/bin/with-contenv bash
# shellcheck shell=bash disable=SC2076
# Autogain routine
#
# Relevant env variables:
# READSB_GAIN: set to "autogain" to enable autogain
# READSB_AUTOGAIN_INITIAL_INTERVAL: time in seconds to run autogain during initial assessment period; 300 if omitted
# READSB_AUTOGAIN_SUBSEQUENT_INTERVAL: time in seconds to run autogain during initial assessment period; 86400 (=1 day) if omitted
# Command to restart autogain: docker exec -it tar1090 /usr/local/bin/autogain1090 reset
READSB_AUTOGAIN_INITIAL_INTERVAL="${READSB_AUTOGAIN_INITIAL_INTERVAL:-300}"
READSB_AUTOGAIN_SUBSEQUENT_INTERVAL="${READSB_AUTOGAIN_SUBSEQUENT_INTERVAL:-86400}"
2023-03-24 14:36:56 +00:00
READSB_AUTOGAIN_INITIAL_TIMEPERIOD="${READSB_AUTOGAIN_INITIAL_TIMEPERIOD:-7200}"
2023-03-24 12:44:41 +00:00
if [[ "${READSB_GAIN,,}" != "autogain" ]]; then
# Autogain is not enabled, so let's do nothing forever
sleep infinity
fi
if [[ "${READSB_DEVICE_TYPE,,}" != "rtlsdr" ]] || [[ -z "${READSB_RTLSDR_DEVICE}" ]]; then
echo "[autogain] ERROR: AUTOGAIN enabled but READSB_DEVICE_TYPE is not \"rtlsdr\" or READSB_RTLSDR_DEVICE serial number not defined. Autogain disabled."
sleep infinity
fi
mkdir -p /var/globe_history/autogain
# Do special things if it's the first time AUTOGAIN is running
if [[ ! -f /var/globe_history/autogain/autogain_initialized ]]; then
2023-03-24 14:36:56 +00:00
# run autogain every $READSB_AUTOGAIN_INITIAL_INTERVAL secs (default 5 mins) for $READSB_AUTOGAIN_INITIAL_TIMEPERIOD secs (default 2 hours)
for (( i=0; i<$(( READSB_AUTOGAIN_INITIAL_TIMEPERIOD / READSB_AUTOGAIN_INITIAL_INTERVAL )); i++ ))
2023-03-24 12:44:41 +00:00
do
sleep "$READSB_AUTOGAIN_INITIAL_INTERVAL" # sleep first to give readsb the opportunity to collect some initial data
/usr/local/bin/autogain1090 2>&1 | mawk -W Interactive '{print "[autogain] " $0}'
done
touch /var/globe_history/autogain/autogain_initialized
fi
while true
do
sleep "$READSB_AUTOGAIN_SUBSEQUENT_INTERVAL"
/usr/local/bin/autogain1090 2>&1 | mawk -W Interactive '{print "[autogain] " $0}'
done