|
|
|
@ -24,6 +24,8 @@ SDR_UNITS=(
|
|
|
|
dronedetector-sdr-2400.service
|
|
|
|
dronedetector-sdr-2400.service
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CONFIGURED_SDR_UNITS=()
|
|
|
|
|
|
|
|
|
|
|
|
log() {
|
|
|
|
log() {
|
|
|
|
printf '[install_all] %s\n' "$*"
|
|
|
|
printf '[install_all] %s\n' "$*"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -33,6 +35,51 @@ die() {
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sdr_unit_env_key() {
|
|
|
|
|
|
|
|
local unit="$1"
|
|
|
|
|
|
|
|
local band="${unit#dronedetector-sdr-}"
|
|
|
|
|
|
|
|
band="${band%.service}"
|
|
|
|
|
|
|
|
printf 'hack_%s\n' "$band"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_env_value() {
|
|
|
|
|
|
|
|
local key="$1"
|
|
|
|
|
|
|
|
awk -F= -v key="$key" '
|
|
|
|
|
|
|
|
$1 == key {
|
|
|
|
|
|
|
|
value = substr($0, index($0, "=") + 1)
|
|
|
|
|
|
|
|
sub(/^[[:space:]]+/, "", value)
|
|
|
|
|
|
|
|
sub(/[[:space:]]+$/, "", value)
|
|
|
|
|
|
|
|
gsub(/^"/, "", value)
|
|
|
|
|
|
|
|
gsub(/"$/, "", value)
|
|
|
|
|
|
|
|
gsub(/^'\''/, "", value)
|
|
|
|
|
|
|
|
gsub(/'\''$/, "", value)
|
|
|
|
|
|
|
|
print value
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
' "${PROJECT_ROOT}/.env"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
populate_configured_sdr_units() {
|
|
|
|
|
|
|
|
CONFIGURED_SDR_UNITS=()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local unit env_key env_value
|
|
|
|
|
|
|
|
for unit in "${SDR_UNITS[@]}"; do
|
|
|
|
|
|
|
|
env_key="$(sdr_unit_env_key "$unit")"
|
|
|
|
|
|
|
|
env_value="$(get_env_value "$env_key")"
|
|
|
|
|
|
|
|
if [[ -n "$env_value" ]]; then
|
|
|
|
|
|
|
|
CONFIGURED_SDR_UNITS+=("$unit")
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
log "Skipping ${unit}: ${env_key} is empty in .env"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ "${#CONFIGURED_SDR_UNITS[@]}" -eq 0 ]]; then
|
|
|
|
|
|
|
|
log "No SDR units are configured in .env"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
log "Configured SDR units: ${CONFIGURED_SDR_UNITS[*]}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print_failure_logs() {
|
|
|
|
print_failure_logs() {
|
|
|
|
log "Collecting diagnostics..."
|
|
|
|
log "Collecting diagnostics..."
|
|
|
|
systemctl --no-pager --full status dronedetector-compose.service || true
|
|
|
|
systemctl --no-pager --full status dronedetector-compose.service || true
|
|
|
|
@ -216,7 +263,7 @@ install_systemd_units() {
|
|
|
|
systemctl enable dronedetector-compose.service
|
|
|
|
systemctl enable dronedetector-compose.service
|
|
|
|
systemctl restart dronedetector-compose.service
|
|
|
|
systemctl restart dronedetector-compose.service
|
|
|
|
|
|
|
|
|
|
|
|
for unit in "${SDR_UNITS[@]}"; do
|
|
|
|
for unit in "${CONFIGURED_SDR_UNITS[@]}"; do
|
|
|
|
systemctl enable "$unit"
|
|
|
|
systemctl enable "$unit"
|
|
|
|
systemctl restart "$unit"
|
|
|
|
systemctl restart "$unit"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
@ -241,7 +288,7 @@ verify_installation() {
|
|
|
|
log "Verifying services"
|
|
|
|
log "Verifying services"
|
|
|
|
|
|
|
|
|
|
|
|
wait_for_systemd_active dronedetector-compose.service 30 || die "dronedetector-compose.service is not active"
|
|
|
|
wait_for_systemd_active dronedetector-compose.service 30 || die "dronedetector-compose.service is not active"
|
|
|
|
for unit in "${SDR_UNITS[@]}"; do
|
|
|
|
for unit in "${CONFIGURED_SDR_UNITS[@]}"; do
|
|
|
|
wait_for_systemd_active "$unit" 45 || die "$unit is not active"
|
|
|
|
wait_for_systemd_active "$unit" 45 || die "$unit is not active"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
@ -251,7 +298,7 @@ verify_installation() {
|
|
|
|
running_services="$(docker compose -f "$COMPOSE_FILE" ps --status running --services || true)"
|
|
|
|
running_services="$(docker compose -f "$COMPOSE_FILE" ps --status running --services || true)"
|
|
|
|
|
|
|
|
|
|
|
|
printf '%s\n' "$running_services" | grep -Fxq "dronedetector-server-to-master" || die "server_to_master is not running"
|
|
|
|
printf '%s\n' "$running_services" | grep -Fxq "dronedetector-server-to-master" || die "server_to_master is not running"
|
|
|
|
printf '%s\n' "$running_services" | grep -Fxq "dronedetector-nn-server" || die "NN_server is not running"
|
|
|
|
printf '%s\n' "$running_services" | grep -Fxq "dronedetector-telemetry-server" || die "telemetry_server is not running"
|
|
|
|
|
|
|
|
|
|
|
|
log "Verification completed"
|
|
|
|
log "Verification completed"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -264,6 +311,7 @@ main() {
|
|
|
|
|
|
|
|
|
|
|
|
extract_local_source_archives
|
|
|
|
extract_local_source_archives
|
|
|
|
preflight
|
|
|
|
preflight
|
|
|
|
|
|
|
|
populate_configured_sdr_units
|
|
|
|
install_host_non_python_deps
|
|
|
|
install_host_non_python_deps
|
|
|
|
setup_sdr_python_env
|
|
|
|
setup_sdr_python_env
|
|
|
|
install_docker_if_needed
|
|
|
|
install_docker_if_needed
|
|
|
|
|