From 507abbfa37394beb40c17679004d95c53f3a2b10 Mon Sep 17 00:00:00 2001 From: wiedehopf Date: Wed, 6 Nov 2024 21:28:52 +0100 Subject: [PATCH] autogain suspend: don't output autogain script messages (#241) --- rootfs/etc/s6-overlay/scripts/autogain | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/autogain b/rootfs/etc/s6-overlay/scripts/autogain index f59b9d5..941abf4 100755 --- a/rootfs/etc/s6-overlay/scripts/autogain +++ b/rootfs/etc/s6-overlay/scripts/autogain @@ -27,13 +27,19 @@ 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++ )) @@ -41,12 +47,13 @@ if [[ ! -f /var/globe_history/autogain/autogain_initialized ]]; then 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