Skip to content

Commit

Permalink
add script to install dumpvdl2
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Sep 24, 2022
1 parent f260535 commit e248ce7
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dumpvdl2/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# custom stuff you can add
OPTIONS0=

# station name for acars.io:
OPTIONS1= --station-id XX-YYYYZ

# gain for rtl-sdr
OPTIONS2= --gain 40

# send data to airframes.io
OPTIONS3= --output decoded:json:udp:address=feed.airframes.io,port=5552

# to have the messages written to disk for human viewing, uncomment the following line:
#OPTIONS4= --output decoded:text:file:path=/var/tmp/dumpvdl2

# rtl-sdr device id or serial:
OPTIONS7= --rtlsdr 0

# frequencies scanned:
OPTIONS8= 136650000 136800000 136975000

73 changes: 73 additions & 0 deletions dumpvdl2/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
set -e
trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR
renice 10 $$

cd /tmp

repo="https://github.com/wiedehopf/adsb-scripts"
ipath=/usr/local/share/adsb-scripts
stuff="build-essential cmake git libglib2.0-dev pkg-config libusb-1.0-0-dev librtlsdr-dev librtlsdr0"
branch="master"

if [[ -n $1 ]]; then
branch="$1"
fi

apt install -y $stuff || apt update && apt install -y $stuff || true

mkdir -p $ipath

function getGIT() {
# getGIT $REPO $BRANCH $TARGET (directory)
if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then echo "getGIT wrong usage, check your script or tell the author!" 1>&2; return 1; fi
REPO="$1"; BRANCH="$2"; TARGET="$3"; pushd .
if cd "$TARGET" &>/dev/null && git fetch --depth 1 origin "$BRANCH" && git reset --hard FETCH_HEAD; then popd; return 0; fi
if ! cd /tmp || ! rm -rf "$TARGET"; then popd; return 1; fi
if git clone --depth 1 --single-branch --branch "$2" "$1" "$3"; then popd; return 0; fi
popd; return 1;
}

# get adsb-scripts repo
getGIT "$repo" master "$ipath/git"

if ! [[ -f "$ipath/libacars-installed" ]]; then
bash "$ipath/git/libacars/install.sh"
fi

cd "$ipath/git/dumpvdl2"

cp service /lib/systemd/system/dumpvdl2.service
cp -n default /etc/default/dumpvdl2

sed -i -e "s/XX-YYYYZ/$RANDOM-$RANDOM/" /etc/default/dumpvdl2

# blacklist kernel driver as on ancient systems
if grep -E 'wheezy|jessie' /etc/os-release -qs; then
echo -e 'blacklist rtl2832\nblacklist dvb_usb_rtl28xxu\nblacklist rtl8192cu\nblacklist rtl8xxxu\n' > /etc/modprobe.d/blacklist-rtl-sdr.conf
rmmod rtl2832 &>/dev/null
rmmod dvb_usb_rtl28xxu &>/dev/null
rmmod rtl8xxxu &>/dev/null
rmmod rtl8192cu &>/dev/null
fi

adduser --system --home $ipath --no-create-home --quiet dumpvdl2
adduser dumpvdl2 plugdev

GIT="$ipath/dumpvdl2-git"
getGIT https://github.com/szpajder/dumpvdl2 "$branch" "$GIT"

cd "$GIT"

rm -rf build
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j2

BIN=/usr/local/bin/dumpvdl2
rm -f $BIN
cp -T src/dumpvdl2 $BIN

systemctl enable dumpvdl2
systemctl restart dumpvdl2
9 changes: 9 additions & 0 deletions dumpvdl2/remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

systemctl disable dumpvdl2
systemctl stop dumpvdl2

ipath=/usr/local/share/adsb-scripts
rm "$ipath/dumpvdl2-git" -rf
rm -v -f /lib/systemd/system/dumpvdl2.service /etc/default/dumpvdl2

27 changes: 27 additions & 0 deletions dumpvdl2/service
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[Unit]
Wants=network.target
After=network.target

[Service]
User=dumpvdl2
EnvironmentFile=/etc/default/dumpvdl2
SyslogIdentifier=dumpvdl2

ExecStart=/usr/local/bin/dumpvdl2 \
$OPTIONS0 \
$OPTIONS1 \
$OPTIONS2 \
$OPTIONS3 \
$OPTIONS4 \
$OPTIONS5 \
$OPTIONS6 \
$OPTIONS7 \
$OPTIONS8 \
$OPTIONS9

Type=simple
Restart=always
RestartSec=30

[Install]
WantedBy=default.target

0 comments on commit e248ce7

Please sign in to comment.