Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autogain suspend: don't output autogain script messages #241

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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