diff --git a/overlay/etc/skel/.config/systemd/user/default.target.wants/et-service-et-api.service b/overlay/etc/skel/.config/systemd/user/default.target.wants/et-service-et-api.service new file mode 120000 index 0000000..f342cf2 --- /dev/null +++ b/overlay/etc/skel/.config/systemd/user/default.target.wants/et-service-et-api.service @@ -0,0 +1 @@ +../et-service-et-api.service \ No newline at end of file diff --git a/overlay/etc/skel/.config/systemd/user/default.target.wants/et-service-mbtileserver.service b/overlay/etc/skel/.config/systemd/user/default.target.wants/et-service-mbtileserver.service new file mode 120000 index 0000000..bf304cb --- /dev/null +++ b/overlay/etc/skel/.config/systemd/user/default.target.wants/et-service-mbtileserver.service @@ -0,0 +1 @@ +../et-service-mbtileserver.service \ No newline at end of file diff --git a/overlay/etc/skel/.config/systemd/user/et-service-dump1090.service b/overlay/etc/skel/.config/systemd/user/et-service-dump1090.service new file mode 100644 index 0000000..b6b9166 --- /dev/null +++ b/overlay/etc/skel/.config/systemd/user/et-service-dump1090.service @@ -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 diff --git a/overlay/etc/skel/.config/systemd/user/et-service-et-api.service b/overlay/etc/skel/.config/systemd/user/et-service-et-api.service new file mode 100644 index 0000000..320b4c1 --- /dev/null +++ b/overlay/etc/skel/.config/systemd/user/et-service-et-api.service @@ -0,0 +1,19 @@ +# Author : Gaston Gonzalez +# Date : 13 August 2025 +# Purpose : User systemd unit file for EmComm Tools API +# +# Usage: +# Check status : systemctl --user status et-service-et-api +# Start service : systemctl --user start et-service-et-api +# Stop service : systemctl --user stop et-service-et-api +# Reload this config : systemctl --user daemon-reload + +[Unit] +Description=EmComm Tools API + +[Service] +ExecStart=/opt/emcomm-tools-api/bin/et-api +Restart=always + +[Install] +WantedBy=default.target diff --git a/overlay/etc/skel/.config/systemd/user/et-service-mbtileserver.service b/overlay/etc/skel/.config/systemd/user/et-service-mbtileserver.service new file mode 100644 index 0000000..aa6f560 --- /dev/null +++ b/overlay/etc/skel/.config/systemd/user/et-service-mbtileserver.service @@ -0,0 +1,19 @@ +# Author : Gaston Gonzalez +# Date : 5 July 2025 +# Purpose : User systemd unit file for EmComm Tools raster tile service +# +# Usage: +# Check status : systemctl --user status et-service-mbtileservice +# Start service : systemctl --user start et-service-mbtileservice +# Stop service : systemctl --user stop et-service-mbtileservice +# Reload this config : systemctl --user daemon-reload + +[Unit] +Description=EmComm Tools raster tile service + +[Service] +ExecStart=/opt/emcomm-tools/bin/et-mbtileserver +Restart=always + +[Install] +WantedBy=default.target diff --git a/overlay/etc/skel/.local/share/emcomm-tools/mbtileserver/tilesets/README.md b/overlay/etc/skel/.local/share/emcomm-tools/mbtileserver/tilesets/README.md new file mode 100644 index 0000000..92513d6 --- /dev/null +++ b/overlay/etc/skel/.local/share/emcomm-tools/mbtileserver/tilesets/README.md @@ -0,0 +1 @@ +Copy your `.mbtiles` file here. diff --git a/overlay/etc/udev/rules.d/99-et-sdr.rules b/overlay/etc/udev/rules.d/99-et-sdr.rules new file mode 100644 index 0000000..e32cdfd --- /dev/null +++ b/overlay/etc/udev/rules.d/99-et-sdr.rules @@ -0,0 +1,15 @@ +# Author : Gaston Gonzalez +# Date : 7 June 2025 +# Purpose : udev rules for supported SDRs +# +# Supported Devices +# 1. RTL-SDR Blog v2 +# +# Preconditions: +# 1. SDR connected via USB cable +# +# Postconditions: +# 1. /dev/et-sdr created + +KERNEL=="swradio0", \ + GROUP="dialout", MODE="0660", SYMLINK+="et-sdr" diff --git a/overlay/opt/emcomm-tools/bin/et-aircraft b/overlay/opt/emcomm-tools/bin/et-aircraft index 3870507..c6a0a93 100755 --- a/overlay/opt/emcomm-tools/bin/et-aircraft +++ b/overlay/opt/emcomm-tools/bin/et-aircraft @@ -2,45 +2,38 @@ # # Author : Gaston Gonzalez # Date : 4 June 2025 -# Update : 5 June 2025 -# Purpose : Wrapper script around dump1090 +# Update : 8 July 2025 +# Purpose : Wrapper script around ADS-B integration # # Preconditions: -# 1. RTL-SDR is connected and detected +# 1. RTL-SDR v2 is connected and detected # # Postconditions: -# 1. dump1099 is launched -# 2. A map is launched - -# TODO: Check for RTL-SDR device -# TODO: Add a systemd user service to start dump1090 -# TODO: Use local offline map -# TODO: Move map to current position -# TODO: Use icon and add to launcher +# 1. dump1099 systemd service is launched +# 2. et-aircraft-app launched source /opt/emcomm-tools/bin/et-common -DUMP1090_CONF_DIR="${HOME}/.local/share/emcomm-tools/dump1090" -DUMP1090_MAP_HTML="${DUMP1090_CONF_DIR}/gmap.html" +CLEAN_UP=1 -if [[ ! -e ${DUMP1090_MAP_HTML} ]]; then - et-log "Map HTML not found: ${DUMP1090_MAP_HTML}" - notify-user "Map HTML not found: ${DUMP1090_MAP_HTML}" +cleanup() { + if [[ ${CLEAN_UP} -eq 1 ]]; then + et-log "Stopping dump1099 service" + systemctl --user stop et-service-dump1090 + fi +} + +# Stop dump1099 on exit +trap cleanup EXIT + +if [[ ! -e ${ET_DEVICE_SDR} ]]; then + notify-user "No ${ET_DEVICE_SDR} detected. Reconnect your SDR." + CLEAN_UP=0 exit 1 fi -CWD_DIR=$(pwd) - -cd ${DUMP1090_CONF_DIR} - -# 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." +systemctl --user restart et-service-dump1090 +if [[ $? -eq 0 ]]; then + start_and_wait_for_service et-service-dump1090 + et-aircraft-app fi - -cd ${CWD_DIR} diff --git a/overlay/opt/emcomm-tools/bin/et-common b/overlay/opt/emcomm-tools/bin/et-common index d14f2f9..bf45cf8 100755 --- a/overlay/opt/emcomm-tools/bin/et-common +++ b/overlay/opt/emcomm-tools/bin/et-common @@ -1,9 +1,15 @@ #!/bin/bash # Author : Gaston Gonzalez # Date : 1 February 2025 -# Updated : 5 June 2025 +# Updated : 7 June 2025 # Purpose : Common environment variables and functions +# Standardized device paths for supported hardware +export ET_DEVICE_AUDIO="/dev/et-audio" +export ET_DEVICE_CAT="/dev/et-cat" +export ET_DEVICE_GPS="/dev/et-gps" +export ET_DEVICE_SDR="/dev/et-sdr" + export ESC="\x1B" export RED="${ESC}[1;31m" export BLUE="${ESC}[1;34m" @@ -22,3 +28,49 @@ show-err-dialog() { notify-user() { notify-send -t 5000 --app-name="EmComm Tools" "$1" } + +exit_if_no_sdr() { + if [[ ! -e ${ET_DEVICE_SDR} ]]; then + et-log "No ${ET_DEVICE_SDR} detected." + exit 1 + fi +} + +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 +} + +start_and_wait_for_service() { + local timeout=15 # Total time to wait in seconds + local interval=2 # Interval between checks in seconds + 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 + + # Do one more check to ensure that we are running, otherwise exit. + exit_on_service_failure ${systemd_unit_name} +} + diff --git a/overlay/opt/emcomm-tools/bin/et-dump1090 b/overlay/opt/emcomm-tools/bin/et-dump1090 new file mode 100755 index 0000000..3d3c0c8 --- /dev/null +++ b/overlay/opt/emcomm-tools/bin/et-dump1090 @@ -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} diff --git a/overlay/opt/emcomm-tools/bin/et-mbtileserver b/overlay/opt/emcomm-tools/bin/et-mbtileserver new file mode 100755 index 0000000..672f728 --- /dev/null +++ b/overlay/opt/emcomm-tools/bin/et-mbtileserver @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Author : Gaston Gonzalez +# Date : 5 July 2025 +# Purpose : Wrapper script for starting the raster tile server +# +# Preconditions: +# 1. At least one .mbtiles files exist in the tileset directory +# +# Postconditions: +# 1. mbtileserver is started +# 2. Tile server available at http://localhost:8000/services + +TILESERVER_HOME="${HOME}/.local/share/emcomm-tools/mbtileserver" +TILESERVER_TILE_DIR="${TILESERVER_HOME}/tilesets" + +start() { + CWD_DIR=$(pwd) + + cd ${TILESERVER_HOME} + CMD="mbtileserver" + et-log "Starting raster tile server in ${TILESERVER_HOME} with: ${CMD}" + + ${CMD} + + cd ${CWD_DIR} +} + +if [[ ! -e ${TILESERVER_TILE_DIR} ]]; then + et-log "Tile set directory does not exist: ${TILESERVER_TILE_DIR}." + exit 1 +fi + +ls ${TILESERVER_TILE_DIR}/*.mbtiles +if [[ $? -ne 0 ]]; then + et-log "Can't start tile server. No .mbtiles in ${TILESERVER_TILE_DIR}" + exit 1 +fi + +start diff --git a/overlay/usr/share/applications/et-aircraft.desktop b/overlay/usr/share/applications/et-aircraft.desktop new file mode 100644 index 0000000..6e03a75 --- /dev/null +++ b/overlay/usr/share/applications/et-aircraft.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Name=et-aircraft +Comment=dump1090 ADB-S tracker for EmComm Tools +Exec=/opt/emcomm-tools/bin/et-aircraft +Icon=et-aircraft-icon-black-192 +Terminal=false +X-MultipleArgs=false +Type=Application +Categories=HamRadio; +StartupNotify=true diff --git a/overlay/usr/share/glib-2.0/schemas/90_ubuntu-settings.gschema.override b/overlay/usr/share/glib-2.0/schemas/90_ubuntu-settings.gschema.override index 8ee080b..13f00af 100644 --- a/overlay/usr/share/glib-2.0/schemas/90_ubuntu-settings.gschema.override +++ b/overlay/usr/share/glib-2.0/schemas/90_ubuntu-settings.gschema.override @@ -12,7 +12,7 @@ show-desktop-icons = false picture-uri = 'file:///usr/share/backgrounds/emcomm-tools-wallpaper.png' [org.gnome.shell] -favorite-apps = ['emcomm-tools.desktop', 'js8call.desktop', 'org.gnome.Terminal.desktop', 'navit.desktop', 'min.desktop', 'org.gnome.Nautilus.desktop'] +favorite-apps = ['emcomm-tools.desktop', 'js8call.desktop', 'et-aircraft.desktop', 'org.gnome.Terminal.desktop', 'navit.desktop', 'min.desktop', 'org.gnome.Nautilus.desktop'] last-selected-power-profile = 'performance' [org.gnome.system.location] diff --git a/overlay/usr/share/icons/et-aircraft-icon-black-192.png b/overlay/usr/share/icons/et-aircraft-icon-black-192.png new file mode 100644 index 0000000..987cadf Binary files /dev/null and b/overlay/usr/share/icons/et-aircraft-icon-black-192.png differ diff --git a/scripts/configure-gnome.sh b/scripts/configure-gnome.sh index d03af38..dee371b 100755 --- a/scripts/configure-gnome.sh +++ b/scripts/configure-gnome.sh @@ -2,17 +2,17 @@ # # Author : Gaston Gonzalez # Date : 16 March 2024 -# Updated : 9 October 2024 +# Updated : 8 June 2025 # Purpose : Configure GNOME -et-log "Configuring GNOME" +et-log "Configuring GNOME..." cp ../overlay/usr/share/glib-2.0/schemas/90_ubuntu-settings.gschema.override \ /usr/share/glib-2.0/schemas/ -cp ../overlay/usr/share/icons/emcomm-tools-icon-black-512.png \ +cp ../overlay/usr/share/icons/*.png \ /usr/share/icons/ -chmod 644 /usr/share/icons/emcomm-tools-*.png +chmod 644 /usr/share/icons/et-*.png glib-compile-schemas /usr/share/glib-2.0/schemas/ diff --git a/scripts/download-et-maps.sh b/scripts/download-et-maps.sh new file mode 100755 index 0000000..058f7d6 --- /dev/null +++ b/scripts/download-et-maps.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Author : Gaston Gonzalez +# Date : 6 July 2025 +# Purpose : Downloads pre-rendered raster map tiles in mbtile format + +BASE_URL="https://github.com/thetechprepper/emcomm-tools-os-community/releases/download" +RELEASE="emcomm-tools-os-community-20250401-r4-final-4.0.0" +TILESET_DIR="/etc/skel/.local/share/emcomm-tools/mbtileserver/tilesets" + +OPTIONS=( + "us" "United States" + "ca" "Canada" +) + +SELECTED_COUNTRY=$(dialog --clear --menu "Select a country" 15 40 5 "${OPTIONS[@]}" 2>&1 >/dev/tty) +EXIT_STATUS=$? + +tput sgr 0 && clear + +if [[ $EXIT_STATUS -eq 0 ]]; then + DOWNLOAD_FILE="osm-${SELECTED_COUNTRY}-zoom0to10-20250703.mbtiles" + DOWNLOAD_URL="${BASE_URL}/${RELEASE}/${DOWNLOAD_FILE}" + + if [[ ! -e ${DOWNLOAD_FILE} ]]; then + et-log "Downloading ${DOWNLOAD_URL}" + curl -L -f -o ${DOWNLOAD_FILE} ${DOWNLOAD_URL} + fi + + et-log "Moving ${DOWNLOAD_FILE} ${TILESET_DIR}" + mv -v ${DOWNLOAD_FILE} ${TILESET_DIR} +fi diff --git a/scripts/install-dump1090.sh b/scripts/install-dump1090.sh index cd0adf1..0ffdd5f 100755 --- a/scripts/install-dump1090.sh +++ b/scripts/install-dump1090.sh @@ -1,7 +1,7 @@ #!/bin/bash # Author : Gaston Gonzalez # Date : 4 June 2025 -# Updated : 5 June 2025 +# Updated : 6 July 2025 # Purpose : Install dump1090 (ADB-S aircraft tracking) set -e trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG @@ -20,7 +20,7 @@ DUMP1090_CONF_DIR="/etc/skel/.local/share/emcomm-tools/dump1090" if [[ ! -e ${ET_DIST_DIR}/${DOWNLOAD_FILE} ]]; then - URL="https://github.com/antirez/dump1090/archive/refs/heads/master.zip" + URL="https://github.com/thetechprepper/dump1090/archive/refs/heads/master.zip" et-log "Downloading ${APP}: ${URL}" curl -s -L -o ${DOWNLOAD_FILE} --fail ${URL} @@ -54,3 +54,7 @@ ln -s ${INSTALL_DIR} ${LINK_PATH} stow -v -d /opt ${APP} -t /usr/local cd $CWD_DIR + +et-log "Updating launcher icon to support PNP..." +cp -v ../overlay/usr/share/applications/et-aircraft.desktop /usr/share/applications/ + diff --git a/scripts/install-et-aircraft.sh b/scripts/install-et-aircraft.sh new file mode 100755 index 0000000..806bd1b --- /dev/null +++ b/scripts/install-et-aircraft.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Author : Gaston Gonzalez +# Date : 9 July 2025 +# Purpose : Install et-aircraft-app +set -e +trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG +trap 'et-log "\"${last_command}\" command failed with exit code $?."' ERR + +. ./env.sh + +APP=et-aircraft-app +VERSION=1.0.0 +DOWNLOAD_FILE="${APP}_${VERSION}_amd64.deb" + +et-log "Installing ${APP} ${VERSION}..." + +if [[ ! -e ${ET_DIST_DIR}/${DOWNLOAD_FILE} ]]; then + + URL="https://github.com/thetechprepper/et-aircraft-app/releases/download/${VERSION}/${DOWNLOAD_FILE}" + + et-log "Downloading ${APP}: ${URL}" + curl -s -L -o ${DOWNLOAD_FILE} --fail ${URL} + + mv ${DOWNLOAD_FILE} ${ET_DIST_DIR} +fi + +DEBIAN_FRONTEND=noninteractive dpkg -i "${ET_DIST_DIR}/${DOWNLOAD_FILE}" diff --git a/scripts/install-et-api.sh b/scripts/install-et-api.sh new file mode 100755 index 0000000..29d517d --- /dev/null +++ b/scripts/install-et-api.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Author : Gaston Gonzalez +# Date : 13 August 2025 +# Purpose : Install EmComm Tools API +set -e +trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG +trap 'et-log "\"${last_command}\" command failed with exit code $?."' ERR + +. ./env.sh + +APP=et-api +VERSION=1.0.0 +ET_API_JAR="emcomm-tools-api-${VERSION}-SNAPSHOT.jar" +BASE_URL="https://github.com/thetechprepper/et-api-java/releases/download/${VERSION}" + +INSTALL_DIR="/opt/emcomm-tools-api" +BIN_DIR="${INSTALL_DIR}/bin" +DATA_DIR="${INSTALL_DIR}/data" +INDEX_DIR="${INSTALL_DIR}/index" + +et-log "Installing ${APP} ${VERSION}..." + +mkdir -v -p "${BIN_DIR}" "${DATA_DIR}" "${INDEX_DIR}" + +# Download and install et-api uber JAR +URL="${BASE_URL}/${ET_API_JAR}" +et-log "Downloading ${APP}: ${URL}" +curl -s -L -o "${BIN_DIR}/${APP}" --fail ${URL} +chmod 755 "${BIN_DIR}/${APP}" + +# Download pre-built data sets +FILES=("faa.csv" "license.csv" "zip2geo.csv" "zip2geo-elevation.csv") +for file in "${FILES[@]}"; do + URL="${BASE_URL}/${file}" + + et-log "Downloading data set: ${URL}" + curl -s -L -o "${DATA_DIR}/${file}" --fail ${URL} +done + +et-log "Applying permissions..." +chgrp -v -R ${ET_GROUP} ${DATA_DIR} ${INDEX_DIR} +chmod -v 775 ${DATA_DIR} ${INDEX_DIR} +chmod -v 664 ${DATA_DIR}/*.csv diff --git a/scripts/install.sh b/scripts/install.sh index c44aa48..cca1524 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -2,7 +2,7 @@ # # Author : Gaston Gonzalez # Date : 16 March 2024 -# Updated : 4 June 2025 +# Updated : 9 July 2025 # Purpose : Main installer for EmComm Tools Community (ETC) . ./env.sh @@ -73,3 +73,9 @@ exitIfNotRoot # Install SDR tools ./install-sdr-tools.sh ./install-dump1090.sh + +# Install ETC custom maps +./download-et-maps.sh + +# Install ETC applications +./install-et-aircraft.sh diff --git a/tests/test-et-aircraft.sh b/tests/test-et-aircraft.sh new file mode 100755 index 0000000..936fe10 --- /dev/null +++ b/tests/test-et-aircraft.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Author : Gaston Gonzalez +# Date : 9 July 2025 +# Purpose : Test et-aircraft installation + +OUT=$(which et-aircraft && which et-aircraft-app) +exit $?