Skip to content

Commit

Permalink
autogain suspend: don't output autogain script messages
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Nov 6, 2024
1 parent 9d0e79a commit 8942149
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions rootfs/etc/s6-overlay/scripts/autogain
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,33 @@ if [[ "${READSB_DEVICE_TYPE,,}" != "rtlsdr" ]]; then
stop_service
fi

mkdir -p /var/globe_history/autogain
autogain_dir="/var/globe_history/autogain"

# if autogain is suspended, sleep for an hour, after that this script will check again if still suspended
[[ -f "${autogain_dir}/suspend" ]] && exec sleep 3600

mkdir -p "${autogain_dir}"

# wait a bit so stats.json is present
sleep 5

# Do special things if it's the first time AUTOGAIN is running
if [[ ! -f /var/globe_history/autogain/autogain_initialized ]]; then
if [[ ! -f $autogain_dir/autogain_initialized ]]; then
[[ -f "${autogain_dir}/suspend" ]] && exec sleep 3600
s6wrap --quiet --prepend=autogain --timestamps --args echo "Autogain initialization started. We'll collect data every $READSB_AUTOGAIN_INITIAL_INTERVAL secs for $(( READSB_AUTOGAIN_INITIAL_TIMEPERIOD / 60 )) minutes to do an initial gain assessment."
# 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++ ))
do
sleep "$READSB_AUTOGAIN_INITIAL_INTERVAL" & wait $! # sleep first to give readsb the opportunity to collect some initial data
s6wrap --quiet --prepend=autogain --timestamps --args /usr/local/bin/autogain1090
done
touch /var/globe_history/autogain/autogain_initialized
touch "${autogain_dir}"/autogain_initialized
fi

s6wrap --quiet --prepend=autogain --timestamps --args echo "Autogain long-term maintenance started. We'll collect data and assess every $(( READSB_AUTOGAIN_SUBSEQUENT_INTERVAL / 60 )) minutes if gain needs to be adjusted."
while true
do
[[ -f "${autogain_dir}/suspend" ]] && exec sleep 3600
sleep "$READSB_AUTOGAIN_SUBSEQUENT_INTERVAL" & wait $!
s6wrap --quiet --prepend=autogain --timestamps --args /usr/local/bin/autogain1090
done

0 comments on commit 8942149

Please sign in to comment.