mirror of
https://github.com/thetechprepper/emcomm-tools-os-community.git
synced 2026-09-17 15:41:44 -04:00
et-mode - Added more robust checks for starting services and their dependencies
This commit is contained in:
@@ -36,7 +36,8 @@ CAT : ${execpi 10 et-system-info et-cat}
|
|||||||
GPS : ${execpi 10 et-system-info et-gps}
|
GPS : ${execpi 10 et-system-info et-gps}
|
||||||
Audio: ${execpi 10 et-system-info et-audio}
|
Audio: ${execpi 10 et-system-info et-audio}
|
||||||
|
|
||||||
Mode : ${execpi 10 et-system-info et-mode}
|
${font DejaVu Sans:bold:size=10}${color #8d5133}${alignc}MODE
|
||||||
|
${font DejaVu Sans Mono:size=11}${color yellow}${execpi 10 et-system-info et-mode}
|
||||||
|
|
||||||
${font DejaVu Sans:bold:size=10}${color #8d5133}${alignc}OPERATOR
|
${font DejaVu Sans:bold:size=10}${color #8d5133}${alignc}OPERATOR
|
||||||
${font DejaVu Sans Mono:size=11}${color yellow}Callsign: ${execpi 10 et-system-info callsign}
|
${font DejaVu Sans Mono:size=11}${color yellow}Callsign: ${execpi 10 et-system-info callsign}
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
#
|
#
|
||||||
# Author : Gaston Gonzalez
|
# Author : Gaston Gonzalez
|
||||||
# Date : 6 November 2024
|
# Date : 6 November 2024
|
||||||
|
# Updated : 7 November 2024
|
||||||
# Purpose : Configures the system for a specific mode of operation
|
# Purpose : Configures the system for a specific mode of operation
|
||||||
|
|
||||||
|
# Use a simple text file to save the state of the last mode selected
|
||||||
MODE_STATUS_FILE="${HOME}/.config/emcomm-tools/et-mode"
|
MODE_STATUS_FILE="${HOME}/.config/emcomm-tools/et-mode"
|
||||||
|
|
||||||
# TODO Add better detection between startup services / apps
|
# List of supported modes of operation
|
||||||
|
|
||||||
MODE_ID_NONE="none"
|
MODE_ID_NONE="none"
|
||||||
MODE_ID_APRS_DIGIPEATER="aprs-digipeater"
|
MODE_ID_APRS_DIGIPEATER="aprs-digipeater"
|
||||||
MODE_ID_APRS_CLIENT="aprs-client"
|
MODE_ID_APRS_CLIENT="aprs-client"
|
||||||
@@ -24,6 +25,34 @@ stop_all_services() {
|
|||||||
systemctl --user stop et-service-direwolf-digipeater
|
systemctl --user stop et-service-direwolf-digipeater
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TIMEOUT=15 # Total time to wait in seconds
|
||||||
|
INTERVAL=2 # Interval between checks in seconds
|
||||||
|
|
||||||
|
start_and_wait_for_service() {
|
||||||
|
local systemd_unit_name="$1"
|
||||||
|
local elapsed=0
|
||||||
|
|
||||||
|
et-log "Starting ${systemd_unit_name}..."
|
||||||
|
systemctl --user start ${systemd_unit_name}
|
||||||
|
|
||||||
|
et-log "Waiting for ${systemd_unit_name} to become active..."
|
||||||
|
|
||||||
|
while ! systemctl is-active --user --quiet "${systemd_unit_name}"; do
|
||||||
|
sleep "$INTERVAL"
|
||||||
|
elapsed=$((elapsed + INTERVAL))
|
||||||
|
if [ "$elapsed" -ge "$TIMEOUT" ]; then
|
||||||
|
et-log "Timeout reached. ${systemd_unit_name} failed to start."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
et-log "Waiting for ${systemd_unit_name} to become active..."
|
||||||
|
done
|
||||||
|
|
||||||
|
# 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
|
||||||
|
}
|
||||||
|
|
||||||
|
# Build list of options
|
||||||
options=()
|
options=()
|
||||||
options+=("${MODE_ID_NONE}" "No mode selected")
|
options+=("${MODE_ID_NONE}" "No mode selected")
|
||||||
options+=("${MODE_ID_APRS_CLIENT}" "APRS Client (YAAC)")
|
options+=("${MODE_ID_APRS_CLIENT}" "APRS Client (YAAC)")
|
||||||
@@ -31,6 +60,7 @@ options+=("${MODE_ID_APRS_DIGIPEATER}" "APRS Digipeater")
|
|||||||
options+=("${MODE_ID_WINLINK_ARDOP}" "Winlink ARDOP")
|
options+=("${MODE_ID_WINLINK_ARDOP}" "Winlink ARDOP")
|
||||||
options+=("${MODE_ID_WINLINK_PACKET}" "Winlink Packet")
|
options+=("${MODE_ID_WINLINK_PACKET}" "Winlink Packet")
|
||||||
|
|
||||||
|
# Prompt user for option and save exit status
|
||||||
SELECTED_MODE=$(dialog --clear --menu "Select a mode:" 20 60 10 "${options[@]}" 3>&1 1>&2 2>&3)
|
SELECTED_MODE=$(dialog --clear --menu "Select a mode:" 20 60 10 "${options[@]}" 3>&1 1>&2 2>&3)
|
||||||
exit_status=$?
|
exit_status=$?
|
||||||
|
|
||||||
@@ -46,24 +76,20 @@ if [ $exit_status -eq 0 ]; then
|
|||||||
;;
|
;;
|
||||||
${MODE_ID_APRS_DIGIPEATER})
|
${MODE_ID_APRS_DIGIPEATER})
|
||||||
systemctl --user start et-service-direwolf-digipeater
|
systemctl --user start et-service-direwolf-digipeater
|
||||||
|
et-log "APRS digipeater now running."
|
||||||
;;
|
;;
|
||||||
${MODE_ID_APRS_CLIENT})
|
${MODE_ID_APRS_CLIENT})
|
||||||
systemctl --user start et-service-direwolf-simple
|
start_and_wait_for_service et-service-direwolf-simple
|
||||||
sleep 3
|
|
||||||
et-yaac start
|
et-yaac start
|
||||||
;;
|
;;
|
||||||
${MODE_ID_WINLINK_ARDOP})
|
${MODE_ID_WINLINK_ARDOP})
|
||||||
systemctl --user start et-service-ardop
|
start_and_wait_for_service et-service-ardop
|
||||||
sleep 3
|
start_and_wait_for_service et-service-winlink-ardop
|
||||||
systemctl --user start et-service-winlink-ardop
|
|
||||||
sleep 3
|
|
||||||
min http://localhost:8080
|
min http://localhost:8080
|
||||||
;;
|
;;
|
||||||
${MODE_ID_WINLINK_PACKET})
|
${MODE_ID_WINLINK_PACKET})
|
||||||
systemctl --user start et-service-direwolf-simple
|
start_and_wait_for_service et-service-direwolf-simple
|
||||||
sleep 3
|
start_and_wait_for_service et-service-winlink-packet
|
||||||
systemctl --user start et-service-winlink-packet
|
|
||||||
sleep 2
|
|
||||||
min http://localhost:8080
|
min http://localhost:8080
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|||||||
Reference in New Issue
Block a user