diff --git a/.github/workflows/debian.yml b/.github/workflows/debian.yml index 9a558d4..64eb243 100644 --- a/.github/workflows/debian.yml +++ b/.github/workflows/debian.yml @@ -1,4 +1,4 @@ -name: Build Debian package +name: Build Debian Package on: push: @@ -10,41 +10,24 @@ env: jobs: build-artifact: - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@master - - name: Install packaging dependencies - run: | - sudo apt-get update -qq - sudo apt-get install -y \ - python3 python3-dev python3-pip python3-venv python3-all \ - dh-python debhelper devscripts dput software-properties-common \ - python3-distutils python3-setuptools python3-wheel python3-stdeb \ - python3-all + - name: Install Debian Package Building Dependencies + run: sudo bash debian/install_pkg_build_deps.sh - - name: Build Debian/Apt sdist_dsc - run: | - python3 -m pip install . - rm -Rf deb_dist/* - python3 setup.py --command-packages=stdeb.command sdist_dsc + - name: Create Debian Package + run: make clean package - - name: Build Debian/Apt bdist_deb - run: | - python3 -m pip install . - export REPO_NAME=$(echo ${{ github.repository }} | awk -F"/" '{print $2}') - python3 setup.py --command-packages=stdeb.command bdist_deb - ls -al deb_dist/ - cp deb_dist/python3-${REPO_NAME}_*_all.deb deb_dist/python3-${REPO_NAME}_latest_all.deb - - - uses: actions/upload-artifact@master + - name: Upload Artifacts to GitHub + uses: actions/upload-artifact@master with: name: artifact-deb - path: | - deb_dist/*.deb + path: deb_dist/*.deb - - name: Create Release + - name: Create GitHub Release id: create_release uses: actions/create-release@master env: @@ -55,7 +38,7 @@ jobs: draft: false prerelease: false - - name: Upload Release Asset + - name: Upload Release Asset to GitHub id: upload-release-asset uses: svenstaro/upload-release-action@v2 with: diff --git a/.github/workflows/python-publish_to_pypi.yml b/.github/workflows/python-publish_to_pypi.yml index ecfcaf3..a068d8a 100644 --- a/.github/workflows/python-publish_to_pypi.yml +++ b/.github/workflows/python-publish_to_pypi.yml @@ -9,31 +9,21 @@ on: jobs: deploy: - runs-on: ubuntu-22.04 - # Specifying a GitHub environment is optional, but strongly encouraged - environment: release - - permissions: - # IMPORTANT: this permission is mandatory for trusted publishing - id-token: write + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.x' - - name: Install dependencies run: | python3 -m pip install --upgrade pip python3 -m pip install setuptools wheel twine - - name: Build run: | python3 setup.py sdist bdist_wheel - - name: Publish package uses: pypa/gh-action-pypi-publish@release/v1 with: diff --git a/.github/workflows/python-test_and_lint.yml b/.github/workflows/python-test_and_lint.yml index f80dec2..14b51c4 100644 --- a/.github/workflows/python-test_and_lint.yml +++ b/.github/workflows/python-test_and_lint.yml @@ -9,11 +9,12 @@ on: jobs: build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: - python-version: [3.9, "3.10", "3.11", "3.12"] + # python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] + python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 44e1e85..24aa63d 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ __pycache__ known_craft.csv .mypy_cache/ .pytest_cache/config.ini +config.ini diff --git a/Makefile b/Makefile index 0fbb2e0..982a4d8 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ +# Makefile from https://github.com/snstac/pytak +# PyTAK Makefile # -# Copyright Sensors & Signals LLC https://www.snstac.com +# Copyright Sensors & Signals LLC https://www.snstac.com/ # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 +# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -14,10 +14,14 @@ # limitations under the License. # -this_app = dronecot -.DEFAULT_GOAL := all +REPO_NAME ?= $(shell echo $(wildcard */__init__.py) | awk -F'/' '{print $$1}') +SHELL := /bin/bash +.DEFAULT_GOAL := editable +# postinst = $(wildcard debian/*.postinst.sh) +# service = $(wildcard debian/*.service) -all: editable +prepare: + mkdir -p build/ develop: python3 setup.py develop @@ -26,13 +30,13 @@ editable: python3 -m pip install -e . install_test_requirements: - python3 -m pip install -r requirements_test.txt + python3 -m pip install -r requirements_test.txt install: python3 setup.py install uninstall: - python3 -m pip uninstall -y $(this_app) + python3 -m pip uninstall -y $(REPO_NAME) reinstall: uninstall install @@ -43,16 +47,16 @@ clean: @rm -rf *.egg* build dist *.py[oc] */*.py[co] cover doctest_pypi.cfg \ nosetests.xml pylint.log output.xml flake8.log tests.log \ test-result.xml htmlcov fab.log .coverage __pycache__ \ - */__pycache__ + */__pycache__ deb_dist .mypy_cache pep8: - flake8 --max-line-length=88 --extend-ignore=E203 --exit-zero $(this_app)/*.py + flake8 --max-line-length=88 --extend-ignore=E203 --exit-zero $(REPO_NAME)/*.py flake8: pep8 lint: pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \ - --max-line-length=88 -r n $(this_app)/*.py || exit 0 + --max-line-length=88 -r n $(REPO_NAME)/*.py || exit 0 pylint: lint @@ -68,11 +72,32 @@ pytest: test: editable install_test_requirements pytest test_cov: - pytest --cov=$(this_app) --cov-report term-missing + pytest --cov=$(REPO_NAME) --cov-report term-missing black: black . mkdocs: pip install -r docs/requirements.txt - mkdocs serve \ No newline at end of file + mkdocs serve + +deb_dist: + python3 setup.py --command-packages=stdeb.command sdist_dsc + +deb_custom: + cp debian/$(REPO_NAME).conf $(wildcard deb_dist/*/debian)/$(REPO_NAME).default + cp debian/$(REPO_NAME).postinst $(wildcard deb_dist/*/debian)/$(REPO_NAME).postinst + cp debian/$(REPO_NAME).service $(wildcard deb_dist/*/debian)/$(REPO_NAME).service + +bdist_deb: deb_dist deb_custom + cd deb_dist/$(REPO_NAME)-*/ && dpkg-buildpackage -rfakeroot -uc -us + +faux_latest: + cp deb_dist/$(REPO_NAME)_*-1_all.deb deb_dist/$(REPO_NAME)_latest_all.deb + cp deb_dist/$(REPO_NAME)_*-1_all.deb deb_dist/python3-$(REPO_NAME)_latest_all.deb + +package: bdist_deb faux_latest + +extract: + dpkg-deb -e $(wildcard deb_dist/*latest_all.deb) deb_dist/extract + dpkg-deb -x $(wildcard deb_dist/*latest_all.deb) deb_dist/extract diff --git a/README.rst b/README.rst index ebab63a..d9f83a2 100644 --- a/README.rst +++ b/README.rst @@ -10,8 +10,6 @@ DroneCOT captures & reports real-time data received from drones into TAK product DroneCOT has been evaluated with WinTAK, iTAK, ATAK & TAK Server. -DroneCOT is in active use today in a variety of missions. - `Documentation is available here. `_ License diff --git a/debian/dronecot.conf b/debian/dronecot.conf new file mode 100644 index 0000000..b11a57b --- /dev/null +++ b/debian/dronecot.conf @@ -0,0 +1,72 @@ +# dronecot.conf from https://github.com/snstac/dronecot +# +# Debian specific runtime configuration for dronecot. +# +# Copyright Sensors & Signals LLC https://www.snstac.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# DroneCOT Configuration: https://dronecot.rtfd.io/ +# Change values here, and restart with: sudo systemctl restart dronecot + +# Enable or Disable the dronecot software daemon. +# ENABLED=1 + +# URL to CoT destination. Must be a URL, e.g. tcp://1.2.3.4:1234 or tls://...:1234, etc. +# COT_URL=udp+wo://239.2.3.1:6969 + +# CoT Stale period ("timeout"), in seconds. +# COT_STALE=3600 + +# Override COT Event Type ("marker type"). +# COT_TYPE=a-u-S-X-M + + + +# PyTAK Configuration: https://pytak.rtfd.io/ +# Change values here, and restart with: sudo systemctl restart aiscot + +# Sets TAK Protocol to use for CoT output. +# TAK_PROTO=0 + +# Sets debug-level logging. Any value other than 0 is considered True. False if unset. +# DEBUG= + +# TAK Data Packages containing TAK Server connection settings, TLS certificates, etc. +# PREF_PACKAGE= + +# Path to a file containing the unencrypted plain-text PEM format Client Certificate. +# This file can contain both the Client Cert & Client Key, or the Client Cert alone. +# In the later case (cert alone), PYTAK_TLS_CLIENT_KEY must be set to the Client Key. +# PYTAK_TLS_CLIENT_CERT= + +# Path to a file containing the unencrypted plain-text PEM format Client Private Key +# for the associated PYTAK_TLS_CLIENT_CERT. +# PYTAK_TLS_CLIENT_KEY= + +# Password for password protected certificates or password protected Private Keys. +# PYTAK_TLS_CLIENT_PASSWORD= + +# Disable destination TLS Certificate Verification. +# PYTAK_TLS_DONT_VERIFY= + +# Disable destination TLS Certificate Common Name (CN) Verification. +# PYTAK_TLS_DONT_CHECK_HOSTNAME= + +# File containing the CA Trust Store to use for remote certificate verification. +# PYTAK_TLS_CLIENT_CAFILE= + +# Expected hostname or CN of the connected server. Not used unless verifying hostname. +# PYTAK_TLS_SERVER_EXPECTED_HOSTNAME= + diff --git a/debian/dronecot.postinst b/debian/dronecot.postinst new file mode 100644 index 0000000..d460b0b --- /dev/null +++ b/debian/dronecot.postinst @@ -0,0 +1,81 @@ +#!/bin/bash +# dronecot.postinst from https://github.com/snstac/dronecot +# +# Copyright Sensors & Signals LLC https://www.snstac.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +echo "dronecot Post Install" + +# shellcheck source=dronecot.conf +[ -f "/etc/default/dronecot" ] && . /etc/default/dronecot + +# Sane defaults: +[ -z "$SERVER_HOME" ] && SERVER_HOME=/run/dronecot +[ -z "$SERVER_USER" ] && SERVER_USER=dronecot +[ -z "$SERVER_NAME" ] && SERVER_NAME="Remote ID to TAK Gateway System User" +[ -z "$SERVER_GROUP" ] && SERVER_GROUP=dronecot + +# Groups that the user will be added to, if undefined, then none. +ADDGROUP="" + +# create user to avoid running server as root +# 1. create group if not existing +if ! getent group | grep -q "^$SERVER_GROUP:" ; then + echo -n "Adding group $SERVER_GROUP.." + addgroup --quiet --system "$SERVER_GROUP" 2>/dev/null ||true + echo "..done" +fi +# 2. create homedir if not existing +test -d "$SERVER_HOME" || mkdir "$SERVER_HOME" +# 3. create user if not existing +if ! getent passwd | grep -q "^$SERVER_USER:"; then + echo -n "Adding system user $SERVER_USER.." + adduser --quiet \ + --system \ + --ingroup "$SERVER_GROUP" \ + --no-create-home \ + --disabled-password \ + "$SERVER_USER" 2>/dev/null || true + echo "..done" +fi +# 4. adjust passwd entry +usermod -c "$SERVER_NAME" \ + -d "$SERVER_HOME" \ + -g "$SERVER_GROUP" \ + "$SERVER_USER" +# 5. adjust file and directory permissions +if ! dpkg-statoverride --list "$SERVER_HOME" >/dev/null +then + chown -R "$SERVER_USER":adm "$SERVER_HOME" + chmod u=rwx,g=rxs,o= "$SERVER_HOME" +fi +# 6. Add the user to the ADDGROUP group +if test -n "$ADDGROUP" +then + if ! groups "$SERVER_USER" | cut -d: -f2 | \ + grep -qw "$ADDGROUP"; then + adduser "$SERVER_USER" "$ADDGROUP" + fi +fi + +systemctl enable dronecot.service + +echo "---- dronecot Install Complete ----" +echo "Documentation: https://dronecot.rtfd.io/" +echo "Configure: sudo nano /etc/default/dronecot" +echo "Start: sudo systemctl start dronecot.service" +echo "Logs: sudo journalctl -fu dronecot" + +exit 0 diff --git a/debian/dronecot.service b/debian/dronecot.service new file mode 100644 index 0000000..56d13e9 --- /dev/null +++ b/debian/dronecot.service @@ -0,0 +1,39 @@ +# dronecot.service from https://github.com/snstac/dronecot +# +# dronecot service for systemd +# +# Copyright Sensors & Signals LLC https://www.snstac.com/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +[Unit] +Description=DroneCOT: Display Drones in TAK +Documentation=https://github.com/snstac/dronecot +Wants=network.target +After=network.target + +[Service] +User=dronecot +ExecStart=/usr/bin/dronecot +RuntimeDirectory=dronecot +SyslogIdentifier=dronecot +EnvironmentFile=/etc/default/dronecot +Type=simple +Restart=always +RestartSec=20 +StartLimitInterval=1 +StartLimitBurst=100 +RestartPreventExitStatus=64 +Nice=-1 + +[Install] +WantedBy=default.target diff --git a/debian/install_pkg_build_deps.sh b/debian/install_pkg_build_deps.sh new file mode 100644 index 0000000..6713a78 --- /dev/null +++ b/debian/install_pkg_build_deps.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "Installing Debian package build dependencies" + +apt-get update -qq + +apt-get install -y \ + python3 python3-dev python3-pip python3-venv python3-all \ + dh-python debhelper devscripts dput software-properties-common \ + python3-distutils python3-setuptools python3-wheel python3-stdeb diff --git a/dronecot/__init__.py b/dronecot/__init__.py index cda37e5..0a885db 100644 --- a/dronecot/__init__.py +++ b/dronecot/__init__.py @@ -16,15 +16,9 @@ # limitations under the License. # -"""Drone Open Remote ID to TAK Gateway. +"""Drone Open Remote ID to TAK Gateway.""" -:source: -""" - -__version__ = "1.0.0-beta5" -__author__ = "Greg Albrecht " -__copyright__ = "Copyright Sensors & Signals LLC https://www.snstac.com" -__license__ = "Apache License, Version 2.0" +__version__ = "1.0.0-beta6" from .constants import ( # NOQA DEFAULT_MQTT_BROKER, diff --git a/dronecot/classes.py b/dronecot/classes.py index 4a37efc..d518450 100644 --- a/dronecot/classes.py +++ b/dronecot/classes.py @@ -30,10 +30,6 @@ import pytak import dronecot -__author__ = "Greg Albrecht " -__copyright__ = "Copyright Sensors & Signals LLC https://www.snstac.com" -__license__ = "Apache License, Version 2.0" - class MQTTWorker(pytak.QueueWorker): """Queue Worker for MQTT.""" diff --git a/dronecot/commands.py b/dronecot/commands.py index a7db558..742ff70 100644 --- a/dronecot/commands.py +++ b/dronecot/commands.py @@ -20,10 +20,6 @@ import pytak -__author__ = "Greg Albrecht " -__copyright__ = "Copyright Sensors & Signals LLC https://www.snstac.com" -__license__ = "Apache License, Version 2.0" - def main() -> None: """Boilerplate main func.""" diff --git a/dronecot/constants.py b/dronecot/constants.py index 4f8cb10..f2609aa 100644 --- a/dronecot/constants.py +++ b/dronecot/constants.py @@ -18,11 +18,6 @@ """DroneCOT Constants.""" -__author__ = "Greg Albrecht " -__copyright__ = "Copyright Sensors & Signals LLC https://www.snstac.com" -__license__ = "Apache License, Version 2.0" - - DEFAULT_MQTT_BROKER: str = "localhost" DEFAULT_MQTT_PORT: int = 1883 DEFAULT_MQTT_TOPIC: str = "#" diff --git a/dronecot/functions.py b/dronecot/functions.py index 68627ec..bd45899 100644 --- a/dronecot/functions.py +++ b/dronecot/functions.py @@ -29,11 +29,6 @@ import pytak import dronecot -__author__ = "Greg Albrecht " -__copyright__ = "Copyright Sensors & Signals LLC https://www.snstac.com" -__license__ = "Apache License, Version 2.0" - - APP_NAME = "dronecot" diff --git a/mkdocs.yml b/mkdocs.yml index 0e4cd5d..a12865a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,7 +1,7 @@ -site_name: DroneCOT - Display Aircraft in TAK +site_name: DroneCOT - Display Drones in TAK site_url: https://dronecot.rtfd.io/ repo_url: https://github.com/snstac/dronecot/ -site_description: Software for monitoring and analyzing aviation surveillance data via the Team Awareness Kit (TAK) ecosystem of products. +site_description: Software for monitoring and analyzing UAS data via the Team Awareness Kit (TAK) ecosystem of products. site_author: Greg Albrecht copyright: Copyright Sensors & Signals LLC https://www.snstac.com diff --git a/setup.cfg b/setup.cfg index a49ef12..7257ffc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,4 @@ -# Setup configuration for DroneCOT: TK +# Setup configuration for DroneCOT # # Copyright Sensors & Signals LLC https://www.snstac.com # @@ -23,7 +23,7 @@ project_urls = CI: GitHub Actions = https://github.com/snstac/dronecot/actions GitHub: issues = https://github.com/snstac/dronecot/issues GitHub: repo = https://github.com/snstac/dronecot -description = TK +description = Display Drones in TAK long_description = file: README.rst long_description_content_type = text/x-rst maintainer = Greg Albrecht @@ -36,6 +36,8 @@ classifiers = Programming Language :: Python Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 diff --git a/stdeb.cfg b/stdeb.cfg new file mode 100644 index 0000000..6a1c41c --- /dev/null +++ b/stdeb.cfg @@ -0,0 +1,4 @@ +[DEFAULT] +Package3: dronecot +Replaces3: python3-dronecot +Depends3: pytak \ No newline at end of file