mirror of
https://github.com/thetechprepper/emcomm-tools-os-community.git
synced 2026-09-17 15:41:44 -04:00
et-aircraft - Added initial support for launching dump1099 as a systemd service. Still a WiP. See remaining TODOs.
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
# Author : Gaston Gonzalez
|
||||||
|
# Date : 7 June 2025
|
||||||
|
# Purpose : User systemd unit file for EmComm Tools dump1090 service
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# Check status : systemctl --user status et-service-dump1090
|
||||||
|
# Start service : systemctl --user start et-service-dump1090
|
||||||
|
# Stop service : systemctl --user stop et-service-dump1090
|
||||||
|
# Reload this config : systemctl --user daemon-reload
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=EmComm Tools dump1090 service
|
||||||
|
# Disable conditional check for SDR device. Allow et-dump1090 to enforce.
|
||||||
|
#ConditionPathExists=/dev/et-sdr
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/opt/emcomm-tools/bin/et-dump1090
|
||||||
|
Restart=no
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -3,63 +3,39 @@
|
|||||||
# Author : Gaston Gonzalez
|
# Author : Gaston Gonzalez
|
||||||
# Date : 4 June 2025
|
# Date : 4 June 2025
|
||||||
# Update : 7 June 2025
|
# Update : 7 June 2025
|
||||||
# Purpose : Wrapper script around dump1090
|
# Purpose : Wrapper script around ADS-B integration
|
||||||
#
|
#
|
||||||
# Preconditions:
|
# Preconditions:
|
||||||
# 1. RTL-SDR v2 is connected and detected
|
# 1. RTL-SDR v2 is connected and detected
|
||||||
#
|
#
|
||||||
# Postconditions:
|
# Postconditions:
|
||||||
# 1. dump1099 is launched
|
# 1. dump1099 systemd service is launched
|
||||||
# 2. A map is launched
|
# 2. Web browser is launched with dump1090 map
|
||||||
|
|
||||||
# TODO: Add a systemd user service to start dump1090
|
# TODO: Check for running service instead of using sleep before Min
|
||||||
# TODO: Use icon and add to launcher
|
# TODO: Use icon and add to launcher
|
||||||
# TODO: Increse size of aircraft
|
# TODO: Increse size of aircraft
|
||||||
# TODO: Research why RTL-SDR v4 does not work
|
# TODO: Research why RTL-SDR v4 does not work
|
||||||
# TODO: Test RTL-SDR v3
|
# TODO: Test RTL-SDR v3
|
||||||
# TODO: Use local new ETC offline map engine
|
# TODO: Use ETC offline map engine
|
||||||
|
|
||||||
source /opt/emcomm-tools/bin/et-common
|
source /opt/emcomm-tools/bin/et-common
|
||||||
|
|
||||||
DUMP1090_CONF_DIR="${HOME}/.local/share/emcomm-tools/dump1090"
|
cleanup() {
|
||||||
DUMP1090_MAP_HTML="${DUMP1090_CONF_DIR}/gmap.html"
|
et-log "Stopping dump1099 service"
|
||||||
|
systemctl --user stop et-service-dump1090
|
||||||
|
}
|
||||||
|
|
||||||
exit-if-no-sdr
|
# Stop dump1099 on exit
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
if [[ ! -e ${DUMP1090_MAP_HTML} ]]; then
|
if [[ ! -e ${ET_DEVICE_SDR} ]]; then
|
||||||
et-log "Map HTML not found: ${DUMP1090_MAP_HTML}"
|
notify-user "No ${ET_DEVICE_SDR} detected. Reconnect your SDR."
|
||||||
notify-user "Map HTML not found: ${DUMP1090_MAP_HTML}"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CWD_DIR=$(pwd)
|
systemctl --user restart et-service-dump1090
|
||||||
|
|
||||||
cd ${DUMP1090_CONF_DIR}
|
|
||||||
|
|
||||||
# TODO: Check if I need to look for /dev/et-gps first
|
|
||||||
MY_LAT_LON=$(et-system-info et-gps)
|
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
if echo "${MY_LAT_LON}" | grep -Eq '^[-+]?[0-9]+(\.[0-9]+)?\s*,\s*[-+]?[0-9]+(\.[0-9]+)?$'; then
|
sleep 10
|
||||||
LAT=$(echo ${MY_LAT_LON} | cut -d "," -f1)
|
min http://localhost:1090 2>/dev/null
|
||||||
LON=$(echo ${MY_LAT_LON} | cut -d "," -f2)
|
|
||||||
ZOOM=10
|
|
||||||
|
|
||||||
sed -i "s/CenterLat=[^;]*;/CenterLat=${LAT};/g" ${DUMP1090_MAP_HTML}
|
|
||||||
sed -i "s/CenterLon=[^;]*;/CenterLon=${LON};/g" ${DUMP1090_MAP_HTML}
|
|
||||||
sed -i "s/setView(\[.*\], *[0-9]*);/setView([${LAT}, ${LON}], ${ZOOM});/" ${DUMP1090_MAP_HTML}
|
|
||||||
|
|
||||||
et-log "Updated map center with your current location."
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# replace with systemd
|
|
||||||
CMD="dump1090 --net --net-http-port 1090"
|
|
||||||
et-log "Starting dump1090 in ${DUMP1090_CONF_DIR} with: ${CMD}"
|
|
||||||
|
|
||||||
${CMD}
|
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
notify-user "RTL-SDR not detected. Please connect it and retry."
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd ${CWD_DIR}
|
|
||||||
|
|||||||
Executable
+55
@@ -0,0 +1,55 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Author : Gaston Gonzalez
|
||||||
|
# Date : 7 June 2025
|
||||||
|
# Purpose : Wrapper script around dump1090
|
||||||
|
#
|
||||||
|
# Preconditions:
|
||||||
|
# 1. RTL-SDR v2 is connected and detected
|
||||||
|
#
|
||||||
|
# Postconditions:
|
||||||
|
# 1. dump1099 map is updated with your position if available
|
||||||
|
# 2. dump1099 is launched with network and HTTP server support
|
||||||
|
|
||||||
|
source /opt/emcomm-tools/bin/et-common
|
||||||
|
|
||||||
|
DUMP1090_CONF_DIR="${HOME}/.local/share/emcomm-tools/dump1090"
|
||||||
|
DUMP1090_MAP_HTML="${DUMP1090_CONF_DIR}/gmap.html"
|
||||||
|
|
||||||
|
exit-if-no-sdr
|
||||||
|
|
||||||
|
if [[ ! -e ${DUMP1090_MAP_HTML} ]]; then
|
||||||
|
et-log "Map HTML not found: ${DUMP1090_MAP_HTML}"
|
||||||
|
notify-user "Map HTML not found: ${DUMP1090_MAP_HTML}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CWD_DIR=$(pwd)
|
||||||
|
|
||||||
|
cd ${DUMP1090_CONF_DIR}
|
||||||
|
|
||||||
|
MY_LAT_LON=$(et-system-info et-gps)
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
if echo "${MY_LAT_LON}" | grep -Eq '^[-+]?[0-9]+(\.[0-9]+)?\s*,\s*[-+]?[0-9]+(\.[0-9]+)?$'; then
|
||||||
|
LAT=$(echo ${MY_LAT_LON} | cut -d "," -f1)
|
||||||
|
LON=$(echo ${MY_LAT_LON} | cut -d "," -f2)
|
||||||
|
ZOOM=10
|
||||||
|
|
||||||
|
sed -i "s/CenterLat=[^;]*;/CenterLat=${LAT};/g" ${DUMP1090_MAP_HTML}
|
||||||
|
sed -i "s/CenterLon=[^;]*;/CenterLon=${LON};/g" ${DUMP1090_MAP_HTML}
|
||||||
|
sed -i "s/setView(\[.*\], *[0-9]*);/setView([${LAT}, ${LON}], ${ZOOM});/" ${DUMP1090_MAP_HTML}
|
||||||
|
|
||||||
|
et-log "Updated map center with your current location."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
CMD="dump1090 --net --net-http-port 1090"
|
||||||
|
et-log "Starting dump1090 in ${DUMP1090_CONF_DIR} with: ${CMD}"
|
||||||
|
|
||||||
|
${CMD}
|
||||||
|
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
et-log "Error starting dump1090."
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ${CWD_DIR}
|
||||||
Reference in New Issue
Block a user