Compare commits
1
Commits
cb87b8ccc6
...
startup
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eeff6e211 |
@@ -1,3 +1,4 @@
|
|||||||
*.out
|
*.out
|
||||||
app
|
app
|
||||||
notes/
|
notes/
|
||||||
|
flightwall.conf
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
[submodule "external/rpi-rgb-led-matrix"]
|
[submodule "external/rpi-rgb-led-matrix"]
|
||||||
path = external/rpi-rgb-led-matrix
|
path = external/rpi-rgb-led-matrix
|
||||||
url = https://github.com/hzeller/rpi-rgb-led-matrix.git
|
url = https://github.com/hzeller/rpi-rgb-led-matrix.git
|
||||||
|
[submodule "external/dump1090"]
|
||||||
|
path = external/dump1090
|
||||||
|
url = https://github.com/flightaware/dump1090
|
||||||
|
|||||||
@@ -1,3 +1,59 @@
|
|||||||
|
## Raspberry Pi setup
|
||||||
|
|
||||||
|
Hardware: an RTL-SDR dongle plugged into the Pi, and the LED matrix wired through the
|
||||||
|
[rpi-rgb-led-matrix](https://github.com/hzeller/rpi-rgb-led-matrix) adapter board.
|
||||||
|
|
||||||
|
On a fresh Raspberry Pi OS / DietPi install:
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone --recurse-submodules https://gitea.dylanbenzi.com/dylan/flightwall
|
||||||
|
cd flightwall
|
||||||
|
sudo ./setup.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
`setup.sh` asks for your latitude, longitude and timezone (saved to `flightwall.conf`), then:
|
||||||
|
|
||||||
|
- installs build dependencies and lighttpd
|
||||||
|
- builds dump1090-fa (pinned submodule in `external/dump1090`) and the FlightWall app
|
||||||
|
- installs three systemd services, enabled on boot:
|
||||||
|
- `flightwall-dump1090` - the ADS-B receiver (SBS output on port 30003)
|
||||||
|
- `flightwall-web` - the dump1090 map / status UI at `http://<pi-ip>:8080`
|
||||||
|
- `flightwall` - the LED display
|
||||||
|
- disables any existing dump1090 / dump1090-fa / readsb service so they don't fight over the dongle
|
||||||
|
- blacklists the DVB kernel drivers that claim the RTL-SDR and the onboard sound module,
|
||||||
|
sets `dtparam=audio=off`, and adds `isolcpus=3` to `cmdline.txt` (4+ core Pis)
|
||||||
|
|
||||||
|
If it reports that the boot config changed, run `sudo reboot`.
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
Edit `flightwall.conf` (created on first setup, not tracked by git):
|
||||||
|
|
||||||
|
| Key | Meaning |
|
||||||
|
| -------------------- | ------------------------------------------------------- |
|
||||||
|
| `LAT`, `LON` | your location, decimal degrees |
|
||||||
|
| `TIMEZONE` | used for day/night brightness |
|
||||||
|
| `SBS_IP`, `SBS_PORT` | where the app reads SBS-1 data (default local dump1090) |
|
||||||
|
| `STALE_SECONDS` | drop aircraft not seen for this long |
|
||||||
|
| `WEB_PORT` | port of the web UI |
|
||||||
|
| `DUMP1090_ARGS` | extra dump1090 flags, e.g. `"--gain 40"` |
|
||||||
|
|
||||||
|
Apply changes with `sudo ./setup.sh` (re-runnable). For `LAT`, `LON`, `SBS_*`, `STALE_SECONDS`
|
||||||
|
or `DUMP1090_ARGS` only, `sudo systemctl restart flightwall-dump1090 flightwall` is enough.
|
||||||
|
|
||||||
|
To update: `git pull --recurse-submodules && sudo ./setup.sh`.
|
||||||
|
|
||||||
|
### Useful commands
|
||||||
|
|
||||||
|
```
|
||||||
|
journalctl -u flightwall -f
|
||||||
|
journalctl -u flightwall-dump1090 -f
|
||||||
|
sudo systemctl restart flightwall
|
||||||
|
nc 127.0.0.1 30003 # raw SBS-1 stream
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
### To clone
|
### To clone
|
||||||
|
|
||||||
`git clone --recurse-submodules https://gitea.dylanbenzi.com/dylan/flightwall`
|
`git clone --recurse-submodules https://gitea.dylanbenzi.com/dylan/flightwall`
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2832", GROUP="plugdev", MODE="0660"
|
||||||
|
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", GROUP="plugdev", MODE="0660"
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=dump1090-fa ADS-B receiver (FlightWall)
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=dump1090
|
||||||
|
EnvironmentFile=__INSTALL_DIR__/flightwall.conf
|
||||||
|
RuntimeDirectory=flightwall-dump1090
|
||||||
|
RuntimeDirectoryMode=0755
|
||||||
|
ExecStart=/usr/local/bin/flightwall-dump1090 --device-type rtlsdr --net --quiet --lat ${LAT} --lon ${LON} --write-json %t/flightwall-dump1090 $DUMP1090_ARGS
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=10
|
||||||
|
Nice=-5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=dump1090 web UI (FlightWall)
|
||||||
|
After=flightwall-dump1090.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=www-data
|
||||||
|
ExecStart=/usr/sbin/lighttpd -D -f /etc/flightwall/lighttpd.conf
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=FlightWall LED display
|
||||||
|
After=network.target flightwall-dump1090.service
|
||||||
|
Wants=flightwall-dump1090.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
EnvironmentFile=__INSTALL_DIR__/flightwall.conf
|
||||||
|
WorkingDirectory=__INSTALL_DIR__
|
||||||
|
ExecStart=__INSTALL_DIR__/app --lat ${LAT} --lon ${LON} --ip ${SBS_IP} --port ${SBS_PORT} --stale ${STALE_SECONDS}
|
||||||
|
Restart=always
|
||||||
|
RestartSec=3
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
server.modules = ("mod_alias", "mod_setenv")
|
||||||
|
server.port = __WEB_PORT__
|
||||||
|
server.document-root = "/usr/local/share/flightwall/html"
|
||||||
|
server.errorlog = "/dev/stderr"
|
||||||
|
server.stat-cache-engine = "disable"
|
||||||
|
index-file.names = ("index.html")
|
||||||
|
|
||||||
|
alias.url = ("/data/" => "/run/flightwall-dump1090/")
|
||||||
|
|
||||||
|
setenv.add-response-header = ("Cache-Control" => "no-cache")
|
||||||
|
|
||||||
|
mimetype.assign = (
|
||||||
|
".html" => "text/html",
|
||||||
|
".css" => "text/css",
|
||||||
|
".js" => "application/javascript",
|
||||||
|
".json" => "application/json",
|
||||||
|
".geojson" => "application/json",
|
||||||
|
".png" => "image/png",
|
||||||
|
".gif" => "image/gif",
|
||||||
|
".svg" => "image/svg+xml",
|
||||||
|
".ico" => "image/x-icon",
|
||||||
|
".txt" => "text/plain"
|
||||||
|
)
|
||||||
+1
Submodule external/dump1090 added at 0339a57b89
@@ -0,0 +1,8 @@
|
|||||||
|
LAT=0
|
||||||
|
LON=0
|
||||||
|
TIMEZONE=America/New_York
|
||||||
|
SBS_IP=127.0.0.1
|
||||||
|
SBS_PORT=30003
|
||||||
|
STALE_SECONDS=60
|
||||||
|
WEB_PORT=8080
|
||||||
|
DUMP1090_ARGS=""
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
echo "Run as root: sudo ./setup.sh" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
CONF="$DIR/flightwall.conf"
|
||||||
|
OWNER="$(stat -c %U "$DIR")"
|
||||||
|
REBOOT=0
|
||||||
|
|
||||||
|
as_owner() {
|
||||||
|
if [ "$OWNER" = "root" ]; then
|
||||||
|
"$@"
|
||||||
|
else
|
||||||
|
runuser -u "$OWNER" -- "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
set_conf() {
|
||||||
|
sed -i -E "s|^$1=.*|$1=$2|" "$CONF"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "==> Configuration"
|
||||||
|
[ -f "$CONF" ] || as_owner cp "$DIR/flightwall.conf.example" "$CONF"
|
||||||
|
. "$CONF"
|
||||||
|
|
||||||
|
is_unset() { [ -z "${1:-}" ] || [ "$1" = "0" ]; }
|
||||||
|
|
||||||
|
if is_unset "$LAT" || is_unset "$LON"; then
|
||||||
|
if [ ! -t 0 ]; then
|
||||||
|
echo "Set LAT and LON in $CONF, then re-run." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
read -rp "Latitude (e.g. 33.6407): " LAT
|
||||||
|
read -rp "Longitude (e.g. -84.4277): " LON
|
||||||
|
current_tz="$(timedatectl show -p Timezone --value 2>/dev/null || echo "$TIMEZONE")"
|
||||||
|
read -rp "Timezone [$current_tz]: " tz
|
||||||
|
TIMEZONE="${tz:-$current_tz}"
|
||||||
|
set_conf LAT "$LAT"
|
||||||
|
set_conf LON "$LON"
|
||||||
|
set_conf TIMEZONE "$TIMEZONE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
num='^-?[0-9]+(\.[0-9]+)?$'
|
||||||
|
if ! [[ "$LAT" =~ $num && "$LON" =~ $num ]]; then
|
||||||
|
echo "LAT/LON in $CONF must be decimal degrees." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! timedatectl list-timezones | grep -qx "$TIMEZONE"; then
|
||||||
|
echo "Unknown TIMEZONE '$TIMEZONE' in $CONF (see: timedatectl list-timezones)." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
timedatectl set-timezone "$TIMEZONE"
|
||||||
|
|
||||||
|
echo "==> Packages"
|
||||||
|
lighttpd_preinstalled=0
|
||||||
|
dpkg -s lighttpd >/dev/null 2>&1 && lighttpd_preinstalled=1
|
||||||
|
apt-get update
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||||
|
build-essential git pkg-config python3 \
|
||||||
|
librtlsdr-dev libusb-1.0-0-dev libncurses-dev lighttpd
|
||||||
|
if [ "$lighttpd_preinstalled" -eq 0 ]; then
|
||||||
|
systemctl disable --now lighttpd 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "==> Building"
|
||||||
|
as_owner git -C "$DIR" submodule update --init --recursive
|
||||||
|
as_owner make -C "$DIR/external/dump1090" -j"$(nproc)" \
|
||||||
|
RTLSDR=yes BLADERF=no HACKRF=no LIMESDR=no SOAPYSDR=no \
|
||||||
|
CPPFLAGS="-Wno-error=format-truncation" dump1090
|
||||||
|
as_owner make -C "$DIR" -j"$(nproc)" app
|
||||||
|
|
||||||
|
echo "==> Installing"
|
||||||
|
install -m 755 "$DIR/external/dump1090/dump1090" /usr/local/bin/flightwall-dump1090
|
||||||
|
rm -rf /usr/local/share/flightwall/html
|
||||||
|
mkdir -p /usr/local/share/flightwall /etc/flightwall
|
||||||
|
cp -r "$DIR/external/dump1090/public_html" /usr/local/share/flightwall/html
|
||||||
|
sed "s|__WEB_PORT__|$WEB_PORT|" "$DIR/deploy/lighttpd.conf" > /etc/flightwall/lighttpd.conf
|
||||||
|
|
||||||
|
getent group plugdev >/dev/null || groupadd --system plugdev
|
||||||
|
id dump1090 >/dev/null 2>&1 ||
|
||||||
|
useradd --system --no-create-home --shell /usr/sbin/nologin -G plugdev dump1090
|
||||||
|
install -m 644 "$DIR/deploy/99-flightwall-rtlsdr.rules" /etc/udev/rules.d/
|
||||||
|
udevadm control --reload-rules && udevadm trigger
|
||||||
|
|
||||||
|
for unit in flightwall flightwall-dump1090 flightwall-web; do
|
||||||
|
sed "s|__INSTALL_DIR__|$DIR|g" "$DIR/deploy/$unit.service" > "/etc/systemd/system/$unit.service"
|
||||||
|
done
|
||||||
|
|
||||||
|
for svc in dump1090 dump1090-fa dump1090-mutability readsb; do
|
||||||
|
if systemctl cat "$svc.service" >/dev/null 2>&1; then
|
||||||
|
echo "Disabling existing $svc service"
|
||||||
|
systemctl disable --now "$svc.service" || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "==> Hardware"
|
||||||
|
cat > /etc/modprobe.d/flightwall.conf <<'EOF'
|
||||||
|
blacklist snd_bcm2835
|
||||||
|
blacklist dvb_usb_rtl28xxu
|
||||||
|
blacklist rtl2832
|
||||||
|
blacklist rtl2830
|
||||||
|
EOF
|
||||||
|
modprobe -r dvb_usb_rtl28xxu rtl2832 rtl2830 2>/dev/null || true
|
||||||
|
|
||||||
|
for boot in /boot/firmware /boot; do
|
||||||
|
[ -f "$boot/cmdline.txt" ] && break
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -f "$boot/cmdline.txt" ] && [ "$(nproc --all)" -ge 4 ] &&
|
||||||
|
! grep -q 'isolcpus=' "$boot/cmdline.txt"; then
|
||||||
|
sed -i -E '1 s/[[:space:]]*$/ isolcpus=3/' "$boot/cmdline.txt"
|
||||||
|
REBOOT=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$boot/config.txt" ]; then
|
||||||
|
if grep -qE '^dtparam=audio=on' "$boot/config.txt"; then
|
||||||
|
sed -i -E 's/^dtparam=audio=on/dtparam=audio=off/' "$boot/config.txt"
|
||||||
|
REBOOT=1
|
||||||
|
elif ! grep -qE '^dtparam=audio=off' "$boot/config.txt"; then
|
||||||
|
echo "dtparam=audio=off" >> "$boot/config.txt"
|
||||||
|
REBOOT=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "==> Services"
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable flightwall-dump1090 flightwall-web flightwall
|
||||||
|
systemctl restart flightwall-dump1090 flightwall-web flightwall
|
||||||
|
|
||||||
|
ip="$(hostname -I | awk '{print $1}')"
|
||||||
|
echo
|
||||||
|
echo "Done. Web UI: http://${ip:-<pi-ip>}:$WEB_PORT"
|
||||||
|
if [ "$REBOOT" -eq 1 ]; then
|
||||||
|
echo "Boot config changed (isolcpus / audio). Reboot to apply: sudo reboot"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user