From d25dfcfaed9d60961bb1bc4f5646d226cb84f317 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Thu, 7 Nov 2024 09:31:11 -0700 Subject: [PATCH] et-mode Added on more method to check the a systemd unit is in fact running --- overlay/opt/emcomm-tools/bin/et-mode | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/overlay/opt/emcomm-tools/bin/et-mode b/overlay/opt/emcomm-tools/bin/et-mode index 152e843..d4e23c5 100755 --- a/overlay/opt/emcomm-tools/bin/et-mode +++ b/overlay/opt/emcomm-tools/bin/et-mode @@ -25,6 +25,15 @@ stop_all_services() { systemctl --user stop et-service-direwolf-digipeater } +exit_on_service_failure() { + local systemd_unit_name="$1" + systemctl is-active --user --quiet "${systemd_unit_name}" + if [ $? -ne 0 ]; then + et-log "Can't start mode. ${systemd_unit_name} failed to start." + exit 1 + fi +} + TIMEOUT=15 # Total time to wait in seconds INTERVAL=2 # Interval between checks in seconds @@ -50,6 +59,9 @@ start_and_wait_for_service() { # Some applications even when started still need a bit of extra time to be available. # Add a short think time of 2 seconds. The ARDOP modem requies extra time. sleep 2 + + # Do one more check to ensure that we are running, otherwise exit. + exit_on_service_failure ${systemd_unit_name} } # Build list of options