Skip to content

Commit

Permalink
Initial container configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fredclausen committed Jan 24, 2022
1 parent 09a7065 commit 2bdcd24
Show file tree
Hide file tree
Showing 14 changed files with 724 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.git*
LICENSE
README.md
retired_scripts
build*.sh
update-local-acars-decoder.sh
Logo-Sources
acarshub-typescript/dist
acarshub-typescript/node_modules
acarshub-typescript/test_assets
rootfs/webapp/static/js
rootfs/webapp/static/airframes-acars-decoder
rootfs/webapp/static/css
docs
retired_scripts
.eslintignore
.pre-commit-config.yaml
notes.txt
update-local-acars-decoder.sh
generate_local_dockerfile.sh
tools
.vscode
tools
rootfs/webapp/static/images/*hour.png
rootfs/webapp/static/images/*hours.png
rootfs/webapp/static/images/*days.png
rootfs/webapp/static/images/*week.png
rootfs/webapp/static/images/*months.png
rootfs/webapp/static/images/*year.png
rootfs/webapp/data/acars-metadata.json
rootfs/webapp/data/metadata.json
rootfs/webapp/data/metadata.json
rootfs/webapp/data/ground-stations.json
libseccomp2-checker.sh
83 changes: 83 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@

# Created by https://www.toptal.com/developers/gitignore/api/macos,linux,windows,vscode
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,linux,windows,vscode

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### vscode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/macos,linux,windows,vscode
69 changes: 69 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-yaml
exclude: ^(rootfs/webapp/static/css/other/|acars-decoder-typescript/|rootfs/webapp/static/js/other/|Logo-Sources|acarshub-typescript/css/other/|acarshub-typescript/js-other)
- id: end-of-file-fixer
exclude: ^(rootfs/webapp/static/css/other/|acars-decoder-typescript/|rootfs/webapp/static/js/other/|Logo-Sources|acarshub-typescript/css/other/|acarshub-typescript/js-other)
- id: trailing-whitespace
exclude: ^(rootfs/webapp/static/css/other/|acars-decoder-typescript/|rootfs/webapp/static/js/other/|Logo-Sources|acarshub-typescript/css/other/|acarshub-typescript/js-other)
- id: requirements-txt-fixer
exclude: ^(rootfs/webapp/static/css/other/|acars-decoder-typescript/|rootfs/webapp/static/js/other/|Logo-Sources|acarshub-typescript/css/other/|acarshub-typescript/js-other)
- id: mixed-line-ending
exclude: ^(rootfs/webapp/static/css/other/|acars-decoder-typescript/|rootfs/webapp/static/js/other/|Logo-Sources|acarshub-typescript/css/other/|acarshub-typescript/js-other)
- repo: https://github.com/IamTheFij/docker-pre-commit
rev: v2.0.1
hooks:
- id: hadolint-system
exclude: ^(rootfs/webapp/static/css/other/|acars-decoder-typescript/|rootfs/webapp/static/js/other/|Logo-Sources|acarshub-typescript/css/other/|acarshub-typescript/js-other)
args:
- "--ignore"
- "DL3003"
- "--ignore"
- "DL3006"
- "--ignore"
- "DL3010"
- "--ignore"
- "DL3008"
- "--ignore"
- "DL4001"
- "--ignore"
- "DL3007"
- repo: https://github.com/psf/black
rev: 21.7b0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v2.3.2' # Use the sha / tag you want to point at
hooks:
- id: prettier
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
types: [file]
additional_dependencies:
- [email protected]
- '@typescript-eslint/eslint-plugin'
exclude: ^(rootfs/webapp/static/css/other/|acars-decoder-typescript/|rootfs/webapp/static/js/other/|Logo-Sources|acarshub-typescript/css/other/|acarshub-typescript/js-other)
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v7.32.0
hooks:
- id: eslint
files: \.[j]sx?$ # *.js, *.jsx, *.ts and *.tsx
types: [file]
exclude: ^(rootfs/webapp/static/css/other/|acars-decoder-typescript/|rootfs/webapp/static/js/other/|Logo-Sources|acarshub-typescript/css/other/|acarshub-typescript/js-other)
additional_dependencies:
- [email protected]
- [email protected]
- [email protected]
# - '@typescript-eslint/eslint-plugin'
# - repo: https://github.com/pre-commit/mirrors-csslint
# rev: 'v1.0.5' # Use the sha / tag you want to point at
# hooks:
# - id: csslint
# exclude: ^rootfs/webapp/static/css/other/
- repo: https://github.com/codespell-project/codespell.git
rev: 'v2.1.0' # Use the sha / tag you want to point at
hooks:
- id: codespell
types: [text]
exclude: ^(rootfs/webapp/static/css/other/|acars-decoder-typescript/|rootfs/webapp/static/js/other/|.+\.json|Logo-Sources|acarshub-typescript/css/other/|acarshub-typescript/js-other|rootfs/webapp/adsb.py|acarshub-typescript/src/interfaces.ts)
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM fredclausen/acarssdr-base:latest

ENV DEVICE_INDEX="" \
QUIET_LOGS="TRUE" \
FREQUENCIES="" \
FEED_ID="" \
PPM="0"\
GAIN="40" \
SERIAL="" \
SERVER="acarshub" \
SERVER_PORT="5555" \
VDLM_FILTER_ENABLE="TRUE"

# hadolint ignore=DL3008,SC2086,SC2039
RUN set -x && \
TEMP_PACKAGES=() && \
KEPT_PACKAGES=() && \
# Required for building multiple packages.
TEMP_PACKAGES+=(build-essential) && \
TEMP_PACKAGES+=(pkg-config) && \
TEMP_PACKAGES+=(cmake) && \
TEMP_PACKAGES+=(git) && \
TEMP_PACKAGES+=(automake) && \
TEMP_PACKAGES+=(autoconf) && \
TEMP_PACKAGES+=(wget) && \
# required for startup checks
KEPT_PACKAGES+=(bc) && \
# packages for dumpvdl2
TEMP_PACKAGES+=(libglib2.0-dev) && \
KEPT_PACKAGES+=(libglib2.0-0) && \
# install packages
apt-get update && \
apt-get install -y --no-install-recommends \
"${KEPT_PACKAGES[@]}" \
"${TEMP_PACKAGES[@]}"\
&& \
pushd /src/ && \
git clone https://github.com/szpajder/dumpvdl2.git && \
pushd dumpvdl2 && \
mkdir build && \
pushd build && \
cmake ../ && \
make && \
make install && \
popd && popd && \
# Clean up
apt-get remove -y "${TEMP_PACKAGES[@]}" && \
apt-get autoremove -y && \
rm -rf /src/* /tmp/* /var/lib/apt/lists/*


COPY rootfs/ /

# ENTRYPOINT [ "/init" ]

# Add healthcheck
HEALTHCHECK --start-period=3600s --interval=600s CMD /scripts/healthcheck.sh
60 changes: 58 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
# docker-dumpvdl2

# Docker dumpvdl2

![Banner](https://github.com/fredclausen/docker-acarshub/blob/16ab3757986deb7c93c08f5c7e3752f54a19629c/Logo-Sources/ACARS%20Hub.png "banner")
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/fredclausen/docker-acarshub/Deploy%20to%20Docker%20Hub)](https://github.com/fredclausen/docker-acarshub/actions?query=workflow%3A%22Deploy+to+Docker+Hub%22)
[![Docker Pulls](https://img.shields.io/docker/pulls/fredclausen/acarshub.svg)](https://hub.docker.com/r/fredclausen/acarshub)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/fredclausen/acarshub/latest)](https://hub.docker.com/r/fredclausen/acarshub)
[![Discord](https://img.shields.io/discord/734090820684349521)](https://discord.gg/sTf9uYF)

Docker container for running [dumpvdl2](https://github.com/szpajder/dumpvdl2) and forwarding the received JSON messages to another system or docker container. Best used alongside [ACARS Hub](https://github.com/fredclausen/acarshub).

Builds and runs on `amd64`, `arm64`, `arm/v7`, `arm/v6` and `386` architectures.

## Note for Users running 32-bit Debian Buster-based OSes on ARM

Please see: [Buster-Docker-Fixes](https://github.com/fredclausen/Buster-Docker-Fixes)!

## Required hardware

A computer host on a suitable architecture and one USB RTL-SDR dongle connected to an antenna.

## Up and running

```yaml
version: '2.0'

services:
dumpvdl2:
image: fredclausen/dumpvdl2:latest
tty: true
container_name: dumpvdl2
restart: always
devices:
- /dev/bus/usb:/dev/bus/usb
ports:
environment:
- TZ="America/Denver"
- SERIAL=13305
- FEED_ID=VDLM
- FREQUENCIES=136725000;136975000;136875000
tmpfs:
- /run:exec,size=64M
- /var/log
```
## Configuration options
| Variable | Description | Required | Default |
|----------|-------------|---------|--------|
| `TZ` | Your timezone | No | UTC |
| `SERIAL` | The serial number of your RTL-SDR dongle | Yes | Blank |
| `FEED_ID` | Used by the decoder to insert a unique ID in to the output message | Yes | Blank |
| `FREQUENCIES` | Colon-separated list of frequencies, but to a maximum of 8, for the decoder to list to. No decimal, and all frequencies should be nine digits long. | Yes | Blank |
| `PPM` | Parts per million correction of the decoder | No | 0 |
| `GAIN`| The gain applied to the RTL-SDR dongle. Recommended to leave at the default autogain. If you want to set the gain manually it is set in tenth of db (ie -g 90 for +9db) | No | `A` for autogain |
| `SERVER` | The server where messages will be forwarded to. | No | Blank |
| `SERVER_PORT` | The port where the server will receive messages on. | No | `5555` |
| `VDLM_FILTER_ENABLE` | Filter out non-informational messages. Turning this off (set to a blank value) will cause increased message rate but the messages will be of little value. Will cause extra SD card read/writes. | No | `TRUE` |
| `QUIET_LOGS` | Mute log output to the bare minimum. Set to a blank value to disable.| No | `TRUE` |
91 changes: 91 additions & 0 deletions rootfs/etc/cont-init.d/01-dumpvdl2
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

# FEED_ID needs to be set

if [[ -z "${FEED_ID}" ]]; then
echo "FEED_ID is not set, exiting"
exit 1
fi

# FREQUENCIES needs to be set

if [[ -z "${FREQUENCIES}" ]]; then
echo "FREQUENCIES is not set, exiting"
exit 1
fi

IFS=';'
read -ra SPLIT_FREQS <<< "${FREQUENCIES}"

# loop through SPLIT_FREQS

# We can only have 6 total frequencies

if [[ "${#SPLIT_FREQS[@]}" -gt 8 ]]; then
echo "FREQUENCIES is too long, exiting"
exit 1
fi

# FREQUENCIES needs to be in the range of 118.0 - 137.0.

FREQ_STRING=""
for i in "${SPLIT_FREQS[@]}"
do
:
# if [[ $(echo "$i > 118.0" | bc) -eq 0 || $(echo "$i < 137.0" | bc) -eq 0 ]]; then
# echo "FREQUENCY $i is not in the range of 118.0 - 137.0, exiting"
# exit 1
# fi
FREQ_STRING+="$i "
done

# Make sure mode is valid

if [[ -n "${SERVER}" && -z "${SERVER_PORT}" ]]; then
echo "SERVER is set but SERVER_PORT is not set, exiting"
exit 1
fi

# DEVICE_ID or SERIAL needs to be set

if [[ -z "${SERIAL}" ]]; then
echo "SERIAL is not set, exiting"
exit 1
fi

RTL_TEST_OUTPUT=$(timeout 1s rtl_test -d 0 2>&1 | grep -P '^\s+\d+:\s+\S+?,\s+\S+?,\s+SN:\s+\S+?\s*$' || true)

IFS=$'\n'
for RTL_TEST_OUTPUT_LINE in $RTL_TEST_OUTPUT; do
# Unset variables in case any regexes fail
unset RTL_DEVICE_ID RTL_DEVICE_MAKE RTL_DEVICE_MODEL RTL_DEVICE_SERIAL

# Pull variables from output via regex
RTL_DEVICE_NUMBER=$(echo "$RTL_TEST_OUTPUT_LINE" | grep -oP '^\s+\K\d+(?=:\s+\S+?,\s+\S+?,\s+SN:\s+\S+?\s*$)')
RTL_DEVICE_SERIAL=$(echo "$RTL_TEST_OUTPUT_LINE" | grep -oP '^\s+\d+:\s+\S+?,\s+\S+?,\s+SN:\s+\K\S+?(?=\s*$)')

# See if we've found the device we're looking for
if [[ -n "$SERIAL" && "$SERIAL" == "$RTL_DEVICE_SERIAL" ]]; then
OUTPUT_DEVICE_ID="$RTL_DEVICE_NUMBER"
fi
done

if [[ -z "${OUTPUT_DEVICE_ID}" ]]; then
echo "Could not find device ID for serial '$SERIAL'"
# exit 1
fi

rm -rf /etc/services.d/dumpvdl2/run > /dev/null 2>&1
cp /etc/templates/run /etc/services.d/dumpvdl2/run
s6-chmod 0755 /etc/services.d/dumpvdl2/run

mkdir -p /run/acars
touch /run/acars/vdlm.past5min.json

sed -i "s/DEVICE_ID=\"\"/DEVICE_ID=\"$OUTPUT_DEVICE_ID\"/g" /etc/services.d/dumpvdl2/run
sed -i "s/FREQ_STRING=\"\"/FREQ_STRING=\"$FREQ_STRING\"/g" /etc/services.d/dumpvdl2/run

# Everything is good to go. Exit with 0

exit 0
Empty file.
Loading

0 comments on commit 2bdcd24

Please sign in to comment.