You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.5 KiB
Bash
73 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
|
|
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
COMPOSE_FILE="${PROJECT_ROOT}/deploy/docker/docker-compose.yml"
|
|
|
|
SDR_UNITS=(
|
|
dronedetector-sdr-433.service
|
|
dronedetector-sdr-750.service
|
|
dronedetector-sdr-868.service
|
|
dronedetector-sdr-3300.service
|
|
dronedetector-sdr-4500.service
|
|
dronedetector-sdr-5200.service
|
|
dronedetector-sdr-5800.service
|
|
dronedetector-sdr-915.service
|
|
dronedetector-sdr-1200.service
|
|
dronedetector-sdr-2400.service
|
|
)
|
|
|
|
log() {
|
|
printf '[restart_all] %s\n' "$*"
|
|
}
|
|
|
|
if [[ -x /usr/bin/sudo ]]; then
|
|
SUDO=(sudo)
|
|
else
|
|
SUDO=()
|
|
fi
|
|
|
|
restart_docker_services() {
|
|
log "Restarting Docker services (without build)"
|
|
|
|
if [[ -f "$COMPOSE_FILE" ]]; then
|
|
docker compose -f "$COMPOSE_FILE" up -d
|
|
else
|
|
log "Compose file not found: $COMPOSE_FILE"
|
|
fi
|
|
|
|
if ${SUDO[@]} systemctl list-unit-files dronedetector-compose.service >/dev/null 2>&1; then
|
|
${SUDO[@]} systemctl restart dronedetector-compose.service || true
|
|
fi
|
|
}
|
|
|
|
restart_sdr_services() {
|
|
log "Restarting SDR systemd units"
|
|
for unit in "${SDR_UNITS[@]}"; do
|
|
${SUDO[@]} systemctl restart "$unit"
|
|
done
|
|
}
|
|
|
|
print_status() {
|
|
log "Docker status"
|
|
docker compose -f "$COMPOSE_FILE" ps || true
|
|
|
|
log "SDR status"
|
|
for unit in "${SDR_UNITS[@]}"; do
|
|
if ${SUDO[@]} systemctl is-active --quiet "$unit"; then
|
|
printf '%s: active\n' "$unit"
|
|
else
|
|
printf '%s: NOT active\n' "$unit"
|
|
fi
|
|
done
|
|
}
|
|
|
|
main() {
|
|
restart_docker_services
|
|
restart_sdr_services
|
|
print_status
|
|
log "Done"
|
|
}
|
|
|
|
main "$@"
|