├── LICENSE ├── README.md ├── acarsdec ├── default ├── install.sh ├── remove.sh └── service ├── autogain-install.sh ├── autogain-remove.sh ├── biastee-disable-978.sh ├── biastee-disable.sh ├── biastee-enable-978.sh ├── biastee-enable.sh ├── dumpvdl2 ├── default ├── install.sh ├── remove.sh └── service ├── fr24-nopackage.sh ├── fr24feed.service ├── fr24feed.service.all ├── inotify-debug.sh ├── install-complete.sh ├── install-dump1090-fa.sh ├── libacars └── install.sh ├── librtlsdr.so.0.6git ├── osm_tiles_offline.sh ├── osm_tiles_offline_10.sh ├── osmocom-rtl-sdr.rules ├── pingfail-install.sh ├── pingfail.service ├── pingfail.sh ├── readsb-install.sh ├── rtl_test.sh ├── simple-storage-test.sh ├── throttled.sh ├── uninstall-complete.sh ├── uninstall-dump1090-fa.sh ├── vdlm2dec ├── default ├── install.sh ├── remove.sh └── service ├── zram-swap-install.sh ├── zram-swap.service ├── zram-swap.sh └── zram-test.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 wiedehopf 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # adsb-scripts 2 | Solutions to common problems using dump1090 variants and ADS-B feeders 3 | 4 | 5 | * [Automatic gain optimization for readsb/dump1090-fa](https://github.com/wiedehopf/adsb-scripts/wiki/Automatic-gain-optimization-for-readsb-and-dump1090-fa) 6 | 7 | * [Automatic installation for readsb](https://github.com/wiedehopf/adsb-scripts/wiki/Automatic-installation-for-readsb) 8 | 9 | * [Automatic installation for dump1090-fa](https://github.com/wiedehopf/adsb-scripts/wiki/Automatic-installation-for-dump1090-fa) 10 | 11 | * [Retro interface for dump1090-fa or readsb](https://github.com/wiedehopf/dump1090-retro-html#dump1090-retro-html) 12 | 13 | * [Guide for Raspbian / debian / Ubuntu](https://github.com/wiedehopf/adsb-wiki/wiki/Raspbian-Lite%3A-ADS-B-receiver) 14 | 15 | * [Misc](https://github.com/wiedehopf/adsb-wiki/wiki) 16 | -------------------------------------------------------------------------------- /acarsdec/default: -------------------------------------------------------------------------------- 1 | OPTIONS0= -v -o 4 -j feed.acars.io:5550 2 | 3 | # station name for acars.io: 4 | OPTIONS1= -i XX-YYYYZ 5 | 6 | # gain for rtl-sdr, for example 43.9 and -10 or 55 for AGC 7 | OPTIONS2= -g 55 8 | 9 | # change to -m 192 for 2.4 MS/s sample rate instead of 2.0 MS/s (might be a bit better) 10 | OPTIONS3= -m 160 11 | 12 | # to have the messages written to disk instead of the journal, uncomment the following line: 13 | # OPTIONS4= -l /var/tmp/acarsdec 14 | 15 | # rtl-sdr device id or serial: 16 | OPTIONS7= -r 0 17 | 18 | # frequencies scanned: 19 | OPTIONS8= 130.025 130.450 131.125 131.525 131.550 131.725 131.825 20 | 21 | -------------------------------------------------------------------------------- /acarsdec/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | set -e 4 | SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd)/$(basename "$0")" 5 | trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR 6 | renice 10 $$ 7 | 8 | cd /tmp 9 | 10 | repo="https://github.com/wiedehopf/adsb-scripts" 11 | ipath=/usr/local/share/adsb-scripts 12 | stuff="git cmake libusb-1.0-0-dev librtlsdr-dev librtlsdr0" 13 | branch="master" 14 | 15 | if [[ -n $1 ]]; then 16 | branch="$1" 17 | fi 18 | 19 | apt install -y $stuff || apt update && apt install -y $stuff || true 20 | 21 | mkdir -p $ipath 22 | 23 | function getGIT() { 24 | # getGIT $REPO $BRANCH $TARGET (directory) 25 | if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then echo "getGIT wrong usage, check your script or tell the author!" 1>&2; return 1; fi 26 | REPO="$1"; BRANCH="$2"; TARGET="$3"; pushd . 27 | if cd "$TARGET" &>/dev/null && git fetch --depth 1 origin "$BRANCH" && git reset --hard FETCH_HEAD; then popd; return 0; fi 28 | if ! cd /tmp || ! rm -rf "$TARGET"; then popd; return 1; fi 29 | if git clone --depth 1 --single-branch --branch "$2" "$1" "$3"; then popd; return 0; fi 30 | popd; return 1; 31 | } 32 | 33 | # get adsb-scripts repo 34 | getGIT "$repo" master "$ipath/git" 35 | 36 | bash "$ipath/git/libacars/install.sh" 37 | 38 | cd "$ipath/git/acarsdec" 39 | 40 | cp service /lib/systemd/system/acarsdec.service 41 | cp -n default /etc/default/acarsdec 42 | 43 | sed -i -e "s/XX-YYYYZ/$RANDOM-$RANDOM/" /etc/default/acarsdec 44 | 45 | # blacklist kernel driver as on ancient systems 46 | if grep -E 'wheezy|jessie' /etc/os-release -qs; then 47 | echo -e 'blacklist rtl2832\nblacklist dvb_usb_rtl28xxu\n' > /etc/modprobe.d/blacklist-rtl-sdr.conf 48 | rmmod rtl2832 &>/dev/null || true 49 | rmmod dvb_usb_rtl28xxu &>/dev/null || true 50 | fi 51 | 52 | adduser --system --home $ipath --no-create-home --quiet acarsdec 53 | adduser acarsdec plugdev 54 | 55 | GIT="$ipath/acarsdec-git" 56 | #getGIT https://github.com/TLeconte/acarsdec "$branch" "$GIT" 57 | getGIT https://github.com/wiedehopf/acarsdec "$branch" "$GIT" 58 | 59 | cd "$GIT" 60 | 61 | rm -rf build 62 | mkdir build 63 | cd build 64 | cmake .. -Drtl=ON 65 | make -j2 66 | 67 | BIN=/usr/local/bin/acarsdec 68 | rm -f $BIN 69 | cp -T acarsdec $BIN 70 | 71 | systemctl enable acarsdec 72 | systemctl restart acarsdec 73 | 74 | echo "-----------------------------------" 75 | echo "$SCRIPT_PATH completed successfully" 76 | echo "-----------------------------------" 77 | -------------------------------------------------------------------------------- /acarsdec/remove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | systemctl disable acarsdec 4 | systemctl stop acarsdec 5 | 6 | ipath=/usr/local/share/adsb-scripts 7 | rm "$ipath/acarsdec-git" -rf 8 | rm -v -f /lib/systemd/system/acarsdec.service /etc/default/acarsdec 9 | 10 | -------------------------------------------------------------------------------- /acarsdec/service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Wants=network.target 3 | After=network.target 4 | 5 | [Service] 6 | User=acarsdec 7 | EnvironmentFile=/etc/default/acarsdec 8 | SyslogIdentifier=acarsdec 9 | 10 | ExecStart=/usr/local/bin/acarsdec \ 11 | $OPTIONS0 \ 12 | $OPTIONS1 \ 13 | $OPTIONS2 \ 14 | $OPTIONS3 \ 15 | $OPTIONS4 \ 16 | $OPTIONS5 \ 17 | $OPTIONS6 \ 18 | $OPTIONS7 \ 19 | $OPTIONS8 \ 20 | $OPTIONS9 21 | 22 | Type=simple 23 | Restart=always 24 | RestartSec=30 25 | 26 | [Install] 27 | WantedBy=default.target 28 | -------------------------------------------------------------------------------- /autogain-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | cd /tmp 4 | 5 | # remove old version: 6 | rm -f /usr/local/bin/dump1090-fa-autogain 7 | rm -f /etc/default/dump1090-fa-autogain 8 | rm -f /etc/cron.d/dump1090-fa-autogain 9 | 10 | systemctl disable dump1090-fa-autogain.timer &>/dev/null 11 | systemctl stop dump1090-fa-autogain.timer &>/dev/null 12 | 13 | rm -f /lib/systemd/system/dump1090-fa-autogain.service 14 | rm -f /lib/systemd/system/dump1090-fa-autogain.timer 15 | 16 | if ! [[ -f /etc/default/readsb ]] && grep -qs /etc/default/dump1090-fa -e 'CONFIG_STYLE.*6' && ! [[ -f /boot/piaware-config.txt ]]; then 17 | echo ------------ 18 | echo dump1090-fa new config style is not supported, sorry. 19 | echo Also dump1090-fa version 6 has its own autogain, that should be sufficient. 20 | echo Try readsb if you want to continue using this script: 21 | echo "https://github.com/wiedehopf/adsb-scripts/wiki/Automatic-installation-for-readsb" 22 | echo ------------ 23 | systemctl disable autogain1090.timer &>/dev/null 24 | systemctl stop autogain1090.timer &>/dev/null 25 | 26 | rm -f /lib/systemd/system/autogain1090.service 27 | rm -f /lib/systemd/system/autogain1090.timer 28 | exit 1 29 | fi 30 | 31 | if ! command -v jq &> /dev/null; then 32 | apt update 33 | apt install -y --no-install-suggests --no-install-recommends jq 34 | hash -r 35 | if ! command -v jq &> /dev/null; then 36 | echo "ERROR: couldn't install jq! FATAL!" 37 | exit 1 38 | fi 39 | fi 40 | 41 | # script to change gain 42 | 43 | mkdir -p /usr/local/bin 44 | cat >/usr/local/bin/autogain1090 <<"EOF" 45 | #!/bin/bash 46 | low=0.5 47 | high=7.0 48 | ga=(0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 -10) 49 | source /etc/default/autogain1090 50 | tmp=/var/tmp/autogain1090 51 | mkdir -p $tmp 52 | 53 | #work around stupid locale stuff 54 | export LC_ALL=C 55 | 56 | APP=dump1090-fa 57 | if [[ -f /run/dump1090-fa/stats.json ]]; then 58 | APP=dump1090-fa 59 | elif [[ -f /run/readsb/stats.json ]]; then 60 | APP=readsb 61 | fi 62 | 63 | stats=/run/$APP/stats.json 64 | 65 | if ! [[ -f $stats ]]; then echo "stats.json not found, is the decoder running?"; exit 1; fi 66 | 67 | oldstrong=$(cat $tmp/strong 2>/dev/null) 68 | oldtotal=$(cat $tmp/total 2>/dev/null) 69 | if [[ -z $oldstrong ]] || [[ -z $oldtotal ]]; then 70 | oldstrong=0 71 | oldtotal=0 72 | fi 73 | 74 | if ! grep -qs total $stats | grep -qs -e strong_signals $stats; then 75 | echo "the decoder doesn't seem to be using an rtl-sdr device, can't help with that." 76 | exit 1 77 | fi 78 | 79 | start=$(jq '.total.start' < $stats) 80 | end=$(jq '.total.end' < $stats) 81 | 82 | strong=$(jq '.total.local.strong_signals' < $stats | tee $tmp/strong) 83 | total=$(jq '.total.local.accepted | add' < $stats | tee $tmp/total) 84 | 85 | if [[ -z $strong ]] || [[ -z $total ]]; then 86 | echo "unrecognized format: $stats" 87 | exit 1 88 | fi 89 | 90 | if ! awk "BEGIN{ exit ($total < 1000) }"; then 91 | echo "The decoder hasn't been running long enough, wait a bit!" 92 | exit 1 93 | fi 94 | 95 | 96 | if [[ $oldtotal > $total ]] || [[ $oldstrong > $strong ]] || [[ $oldtotal == $total ]]; then 97 | oldstrong=0 98 | oldtotal=0 99 | fi 100 | 101 | strong=$((strong - oldstrong)) 102 | total=$((total - oldtotal)) 103 | 104 | if [[ $total == 0 ]]; then 105 | percent=0 106 | else 107 | percent=$(awk "BEGIN {printf \"%.3f\", $strong * 100 / $total}") 108 | fi 109 | 110 | strong=$percent 111 | 112 | if [[ $strong == "nan" ]]; then echo "Error, can't automatically adjust gain!"; exit 1; fi 113 | 114 | if [ -f /boot/adsb-config.txt ]; then 115 | oldgain=$(grep -P -e 'GAIN=\K[0-9-.]*' -o /boot/adsb-config.txt) 116 | else 117 | oldgain=$(grep -P -e 'gain \K[0-9-.]*' -o /etc/default/$APP) 118 | fi 119 | 120 | if [[ "$oldgain" == "" ]]; then 121 | oldgain=44 122 | fi 123 | 124 | gain_index=28 125 | for i in "${!ga[@]}"; do 126 | if ! awk "BEGIN{ exit (${oldgain} <= ${ga[$i]}) }"; then 127 | gain_index="${i}" 128 | break 129 | fi 130 | done 131 | 132 | if ! awk "BEGIN{ exit (${oldgain} > 49.6) }"; then 133 | gain_index=28 134 | fi 135 | 136 | if [[ "$oldgain" == "-10" ]]; then 137 | gain_index=29 138 | fi 139 | 140 | 141 | if ! awk "BEGIN{ exit ($strong > $low) }" && ! awk "BEGIN{ exit ($strong < $high) }"; then 142 | echo "No gain change needed, percentage of messages >-3dB is in nominal range. (${strong}%)" 143 | exit 0 144 | 145 | fi 146 | 147 | if ! awk "BEGIN{ exit ($strong < $low) }" && [[ $gain_index == 29 ]]; then 148 | echo "Gain already at maximum! (${strong}% messages >-3dB)" 149 | exit 0 150 | fi 151 | 152 | if ! awk "BEGIN{ exit ($strong < $low) }"; then 153 | gain_index=$(($gain_index+1)) 154 | action=Increasing 155 | fi 156 | 157 | if ! awk "BEGIN{ exit ($strong > $high) }" && [[ $gain_index == 0 ]]; then 158 | echo "Gain already at minimum! (${strong}% messages >-3dB)" 159 | exit 0 160 | fi 161 | 162 | if ! awk "BEGIN{ exit ($strong > $high) }"; then 163 | gain_index=$(($gain_index-1)) 164 | action=Decreasing 165 | fi 166 | 167 | gain="${ga[$gain_index]}" 168 | 169 | if [[ $gain == "" ]]; then echo "Gain already at maximum! (${strong}% messages >-3dB)"; exit 0; fi 170 | 171 | if [ -f /boot/piaware-config.txt ]; then 172 | piaware-config rtlsdr-gain $gain 173 | fi 174 | 175 | if [ -f /boot/adsb-config.txt ]; then 176 | sed --follow-symlinks -i -E -e "s/^GAIN.*/GAIN=$gain/" /boot/adsb-config.txt 177 | else 178 | if ! grep gain /etc/default/$APP &>/dev/null && grep -E 'device-type.*rtlsdr' /etc/default/$APP &>/dev/null; then 179 | sed --follow-symlinks -i -e 's/RECEIVER_OPTIONS="/RECEIVER_OPTIONS="--gain 49.6 /' /etc/default/$APP 180 | fi 181 | sed --follow-symlinks -i -E -e "s/--gain -?[0-9]*\.?[0-9]*/--gain $gain/" /etc/default/$APP 182 | fi 183 | 184 | systemctl restart $APP 185 | 186 | #reset numbers 187 | echo 0 > $tmp/strong 188 | echo 0 > $tmp/total 189 | 190 | echo "$action gain to $gain (${strong}% messages >-3dB)" 191 | EOF 192 | chmod a+x /usr/local/bin/autogain1090 193 | 194 | config_file=/etc/default/autogain1090 195 | if ! [ -f $config_file ]; then 196 | cat >/etc/default/autogain1090 <<"EOF" 197 | #!/bin/bash 198 | 199 | low=0.5 200 | high=7.0 201 | 202 | ga=(0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 -10) 203 | EOF 204 | fi 205 | 206 | rm -f /etc/cron.d/autogain1090 207 | 208 | cat >/lib/systemd/system/autogain1090.service <<"EOF" 209 | [Unit] 210 | Description=autogain for readsb or dump1090-fa 211 | 212 | [Service] 213 | ExecStart=/usr/local/bin/autogain1090 214 | EOF 215 | 216 | cat >/lib/systemd/system/autogain1090.timer <<"EOF" 217 | [Unit] 218 | Description=Nightly automatic gain adjustment for readsb or dump1090-fa 219 | 220 | [Timer] 221 | OnCalendar=*-*-* 02:30:00 222 | RandomizedDelaySec=30m 223 | 224 | [Install] 225 | WantedBy=timers.target 226 | EOF 227 | 228 | if grep jessie /etc/os-release >/dev/null; then 229 | sed --follow-symlinks -i -e '/Randomized/d' /lib/systemd/system/autogain1090.timer 230 | fi 231 | 232 | 233 | systemctl daemon-reload 234 | systemctl enable autogain1090.timer 235 | systemctl restart autogain1090.timer 236 | 237 | 238 | echo -------------- 239 | echo "All done!" 240 | 241 | -------------------------------------------------------------------------------- /autogain-remove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | 4 | rm -f /usr/local/bin/autogain1090 5 | rm -f /etc/default/autogain1090 6 | rm -f /etc/cron.d/autogain1090 7 | 8 | systemctl disable autogain1090.timer &>/dev/null 9 | systemctl stop autogain1090.timer &>/dev/null 10 | 11 | rm -f /lib/systemd/system/autogain1090.service 12 | rm -f /lib/systemd/system/autogain1090.timer 13 | 14 | 15 | # remove old naming 16 | rm -f /usr/local/bin/dump1090-fa-autogain 17 | rm -f /etc/default/dump1090-fa-autogain 18 | rm -f /etc/cron.d/dump1090-fa-autogain 19 | 20 | systemctl disable dump1090-fa-autogain.timer &>/dev/null 21 | systemctl stop dump1090-fa-autogain.timer &>/dev/null 22 | 23 | rm -f /lib/systemd/system/dump1090-fa-autogain.service 24 | rm -f /lib/systemd/system/dump1090-fa-autogain.timer 25 | 26 | systemctl daemon-reload 27 | 28 | echo -------------- 29 | echo "autogain.sh: Uninstall complete!" 30 | 31 | -------------------------------------------------------------------------------- /biastee-disable-978.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | set -e 4 | ipath=/usr/local/share/adsb-wiki/biastee 5 | APPS="dump978-fa" 6 | 7 | for APP in $APPS; do 8 | rm -f /etc/systemd/system/$APP.service.d/bias-t.conf 9 | done 10 | 11 | systemctl daemon-reload 12 | 13 | for APP in $APPS; do 14 | if systemctl show $APP 2>/dev/null | grep -qs 'UnitFileState=enabled'; then 15 | systemctl stop $APP || true 16 | /usr/local/share/adsb-wiki/biastee/rtl_biast/build/src/rtl_biast -b 0 || true 17 | systemctl restart $APP || true 18 | fi 19 | done 20 | rm -rf $ipath 21 | 22 | echo ----- all done ------ 23 | -------------------------------------------------------------------------------- /biastee-disable.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | set -e 4 | ipath=/usr/local/share/adsb-wiki/biastee 5 | APPS="dump1090-fa readsb" 6 | 7 | for APP in $APPS; do 8 | if systemctl show $APP 2>/dev/null | grep -qs 'UnitFileState=enabled'; then 9 | systemctl stop $APP || true 10 | fi 11 | done 12 | 13 | for APP in $APPS; do 14 | rm -f /etc/systemd/system/$APP.service.d/bias-t.conf 15 | done 16 | 17 | systemctl daemon-reload 18 | 19 | for APP in $APPS; do 20 | if systemctl show $APP 2>/dev/null | grep -qs 'UnitFileState=enabled'; then 21 | systemctl stop $APP || true 22 | /usr/local/share/adsb-wiki/biastee/rtl_biast/build/src/rtl_biast -b 0 || true 23 | systemctl restart $APP || true 24 | fi 25 | done 26 | rm -rf $ipath 27 | 28 | echo ----- all done ------ 29 | -------------------------------------------------------------------------------- /biastee-enable-978.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | renice 10 $$ 4 | set -e 5 | if ! command -v git &>/dev/null || ! command -v cmake &>/dev/null; then 6 | apt update 7 | apt install -y --no-install-suggests --no-install-recommends make cmake git build-essential libusb-1.0-0-dev 8 | fi 9 | ipath=/usr/local/share/adsb-wiki/biastee 10 | APPS="dump978-fa" 11 | rm -rf $ipath 12 | mkdir -p $ipath 13 | cd $ipath 14 | git clone --depth 1 https://github.com/rtlsdrblog/rtl_biast 15 | cd rtl_biast 16 | pushd . 17 | 18 | mkdir build 19 | cd build 20 | cmake .. -DDETACH_KERNEL_DRIVER=ON 21 | make 22 | 23 | popd 24 | 25 | for APP in $APPS; do 26 | mkdir -p /etc/systemd/system/$APP.service.d 27 | cat > /etc/systemd/system/$APP.service.d/bias-t.conf << "EOF" 28 | [Service] 29 | ExecStartPre=/usr/local/share/adsb-wiki/biastee/rtl_biast/build/src/rtl_biast -b 1 30 | ExecStopPost=/usr/local/share/adsb-wiki/biastee/rtl_biast/build/src/rtl_biast -b 0 31 | EOF 32 | 33 | done 34 | 35 | systemctl daemon-reload 36 | for APP in $APPS; do 37 | if systemctl show $APP 2>/dev/null | grep -qs 'UnitFileState=enabled'; then 38 | echo biastee will be enabled on $APP start 39 | echo restarting $APP 40 | systemctl restart $APP || true 41 | fi 42 | done 43 | 44 | echo ----- all done ------ 45 | -------------------------------------------------------------------------------- /biastee-enable.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | renice 10 $$ 4 | set -e 5 | function aptInstall() { 6 | if ! apt install -y --no-install-recommends --no-install-suggests "$@"; then 7 | apt update 8 | apt install -y --no-install-recommends --no-install-suggests "$@" 9 | fi 10 | } 11 | 12 | aptInstall make cmake git build-essential libusb-1.0-0-dev librtlsdr-dev 13 | 14 | ipath=/usr/local/share/adsb-wiki/biastee 15 | APPS="dump1090-fa readsb" 16 | rm -rf $ipath 17 | mkdir -p $ipath 18 | cd $ipath 19 | git clone --depth 1 https://github.com/rtlsdrblog/rtl_biast 20 | cd rtl_biast 21 | pushd . 22 | 23 | mkdir build 24 | cd build 25 | cmake .. -DDETACH_KERNEL_DRIVER=ON 26 | make 27 | 28 | popd 29 | 30 | for APP in $APPS; do 31 | if systemctl show $APP 2>/dev/null | grep -qs 'UnitFileState=enabled'; then 32 | echo stopping $APP 33 | systemctl stop $APP || true 34 | fi 35 | done 36 | 37 | for APP in $APPS; do 38 | mkdir -p /etc/systemd/system/$APP.service.d 39 | cat > /etc/systemd/system/$APP.service.d/bias-t.conf << "EOF" 40 | [Service] 41 | ExecStartPre=/usr/local/share/adsb-wiki/biastee/rtl_biast/build/src/rtl_biast -b 1 42 | ExecStopPost=/usr/local/share/adsb-wiki/biastee/rtl_biast/build/src/rtl_biast -b 0 43 | EOF 44 | 45 | done 46 | 47 | systemctl daemon-reload 48 | for APP in $APPS; do 49 | if systemctl show $APP 2>/dev/null | grep -qs 'UnitFileState=enabled'; then 50 | echo biastee will be enabled on $APP start 51 | echo restarting $APP 52 | systemctl restart $APP || true 53 | fi 54 | done 55 | 56 | echo ----- all done ------ 57 | -------------------------------------------------------------------------------- /dumpvdl2/default: -------------------------------------------------------------------------------- 1 | # custom stuff you can add 2 | OPTIONS0= 3 | 4 | # station name for acars.io: 5 | OPTIONS1= --station-id XX-YYYYZ 6 | 7 | # gain for rtl-sdr 8 | OPTIONS2= --gain 40 9 | 10 | # send data to airframes.io 11 | OPTIONS3= --output decoded:json:udp:address=feed.airframes.io,port=5552 12 | 13 | # to have the messages written to disk for human viewing, uncomment the following line: 14 | #OPTIONS4= --output decoded:text:file:path=/var/tmp/dumpvdl2 15 | 16 | # rtl-sdr device id or serial: 17 | OPTIONS7= --rtlsdr 0 18 | 19 | # frequencies scanned: 20 | OPTIONS8= 136650000 136800000 136975000 21 | 22 | -------------------------------------------------------------------------------- /dumpvdl2/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | set -e 4 | SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd)/$(basename "$0")" 5 | trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR 6 | renice 10 $$ 7 | 8 | cd /tmp 9 | 10 | repo="https://github.com/wiedehopf/adsb-scripts" 11 | ipath=/usr/local/share/adsb-scripts 12 | stuff="build-essential cmake git libglib2.0-dev pkg-config libusb-1.0-0-dev librtlsdr-dev librtlsdr0" 13 | branch="master" 14 | 15 | if [[ -n $1 ]]; then 16 | branch="$1" 17 | fi 18 | 19 | apt install -y $stuff || apt update && apt install -y $stuff || true 20 | 21 | mkdir -p $ipath 22 | 23 | function getGIT() { 24 | # getGIT $REPO $BRANCH $TARGET (directory) 25 | if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then echo "getGIT wrong usage, check your script or tell the author!" 1>&2; return 1; fi 26 | REPO="$1"; BRANCH="$2"; TARGET="$3"; pushd . 27 | if cd "$TARGET" &>/dev/null && git fetch --depth 1 origin "$BRANCH" && git reset --hard FETCH_HEAD; then popd; return 0; fi 28 | if ! cd /tmp || ! rm -rf "$TARGET"; then popd; return 1; fi 29 | if git clone --depth 1 --single-branch --branch "$2" "$1" "$3"; then popd; return 0; fi 30 | popd; return 1; 31 | } 32 | 33 | # get adsb-scripts repo 34 | getGIT "$repo" master "$ipath/git" 35 | 36 | bash "$ipath/git/libacars/install.sh" 37 | 38 | cd "$ipath/git/dumpvdl2" 39 | 40 | cp service /lib/systemd/system/dumpvdl2.service 41 | cp -n default /etc/default/dumpvdl2 42 | 43 | sed -i -e "s/XX-YYYYZ/$RANDOM-$RANDOM/" /etc/default/dumpvdl2 44 | 45 | # blacklist kernel driver as on ancient systems 46 | if grep -E 'wheezy|jessie' /etc/os-release -qs; then 47 | echo -e 'blacklist rtl2832\nblacklist dvb_usb_rtl28xxu\n' > /etc/modprobe.d/blacklist-rtl-sdr.conf 48 | rmmod rtl2832 &>/dev/null || true 49 | rmmod dvb_usb_rtl28xxu &>/dev/null || true 50 | fi 51 | 52 | adduser --system --home $ipath --no-create-home --quiet dumpvdl2 53 | adduser dumpvdl2 plugdev 54 | 55 | GIT="$ipath/dumpvdl2-git" 56 | getGIT https://github.com/szpajder/dumpvdl2 "$branch" "$GIT" 57 | 58 | cd "$GIT" 59 | 60 | rm -rf build 61 | mkdir build 62 | cd build 63 | cmake -DCMAKE_BUILD_TYPE=Release .. 64 | make -j2 65 | 66 | BIN=/usr/local/bin/dumpvdl2 67 | rm -f $BIN 68 | cp -T src/dumpvdl2 $BIN 69 | 70 | systemctl enable dumpvdl2 71 | systemctl restart dumpvdl2 72 | 73 | echo "-----------------------------------" 74 | echo "$SCRIPT_PATH completed successfully" 75 | echo "-----------------------------------" 76 | -------------------------------------------------------------------------------- /dumpvdl2/remove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | systemctl disable dumpvdl2 4 | systemctl stop dumpvdl2 5 | 6 | ipath=/usr/local/share/adsb-scripts 7 | rm "$ipath/dumpvdl2-git" -rf 8 | rm -v -f /lib/systemd/system/dumpvdl2.service /etc/default/dumpvdl2 9 | 10 | -------------------------------------------------------------------------------- /dumpvdl2/service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Wants=network.target 3 | After=network.target 4 | 5 | [Service] 6 | User=dumpvdl2 7 | EnvironmentFile=/etc/default/dumpvdl2 8 | SyslogIdentifier=dumpvdl2 9 | 10 | ExecStart=/usr/local/bin/dumpvdl2 \ 11 | $OPTIONS0 \ 12 | $OPTIONS1 \ 13 | $OPTIONS2 \ 14 | $OPTIONS3 \ 15 | $OPTIONS4 \ 16 | $OPTIONS5 \ 17 | $OPTIONS6 \ 18 | $OPTIONS7 \ 19 | $OPTIONS8 \ 20 | $OPTIONS9 21 | 22 | Type=simple 23 | Restart=always 24 | RestartSec=30 25 | 26 | [Install] 27 | WantedBy=default.target 28 | -------------------------------------------------------------------------------- /fr24-nopackage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | 4 | apt update 5 | apt install -y perl wget 6 | 7 | # remove fr24feed in package form 8 | apt purge -y fr24feed 9 | # remove the fr24feed updater (should be removed with the package but let's make real sure) 10 | rm -f /etc/cron.d/fr24feed_updater 11 | 12 | set -e 13 | 14 | if ! id -u fr24 &>/dev/null; then 15 | adduser --system --no-create-home fr24 || true 16 | addgroup fr24 || true 17 | adduser fr24 fr24 || true 18 | fi 19 | cd 20 | rm /tmp/fr24 -rf 21 | mkdir -p /tmp/fr24 22 | cd /tmp 23 | 24 | wget -O fr24.deb https://repo-feed.flightradar24.com/rpi_binaries/fr24feed_1.0.51-0_armhf.deb 25 | 26 | dpkg -x fr24.deb fr24 27 | cp -f fr24/usr/bin/fr24feed* /usr/bin 28 | 29 | if ! [[ -f /etc/fr24feed.ini ]]; then 30 | cat >/etc/fr24feed.ini << "EOF" 31 | bs=no 32 | raw=no 33 | mlat="no" 34 | mlat-without-gps="no" 35 | EOF 36 | fi 37 | 38 | chmod 666 /etc/fr24feed.ini 39 | 40 | 41 | wget -O /etc/systemd/system/fr24feed.service https://raw.githubusercontent.com/wiedehopf/adsb-scripts/master/fr24feed.service 42 | systemctl enable fr24feed 43 | 44 | 45 | echo ---------------------------- 46 | echo fr24feed installed / updated! 47 | echo ---------------------------- 48 | -------------------------------------------------------------------------------- /fr24feed.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Flightradar24 Decoder & Feeder 3 | After=network-online.target 4 | 5 | [Service] 6 | Type=simple 7 | Restart=always 8 | ExecStartPre=-/bin/rm -f /dev/shm/decoder.txt 9 | ExecStopPost=-/bin/rm -f /dev/shm/decoder.txt 10 | 11 | ExecStart=/bin/bash -c "stdbuf -oL -eL /usr/bin/fr24feed | stdbuf -oL -eL sed -u -e 's/[0-9,-]* [0-9,:]* | //' | stdbuf -oL -eL grep -v -e '::on_periodic_refresh:' -e 'Synchronizing time via NTP' -e 'synchronized correctly' -e 'Pinging' -e 'time references AC' -e 'mlat.... [A-F,0-9]*' -e '.feed..n.ping ' -e 'syncing stream' -e 'saving bandwidth' | stdbuf -oL -eL perl -ne 'print if (not /mlat..i.Stats/ or ($n++ % 58 == 3)) and (not /feed....sent/ or ($m++ % 250 == 10)) and (not /sent.*aircraft/ or ($m++ % 250 == 10)) and (not /stats.sent/ or ($k++ % 6 == 1)) ;$|=1'" 12 | 13 | LimitNOFILE=256 14 | User=fr24 15 | PermissionsStartOnly=true 16 | SyslogIdentifier=fr24feed 17 | SendSIGHUP=yes 18 | TimeoutStopSec=5 19 | RestartSec=0 20 | StartLimitInterval=5 21 | StartLimitBurst=20 22 | 23 | [Install] 24 | WantedBy=multi-user.target 25 | -------------------------------------------------------------------------------- /fr24feed.service.all: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Flightradar24 Decoder & Feeder 3 | After=network-online.target 4 | 5 | [Service] 6 | Type=simple 7 | Restart=always 8 | ExecStartPre=-/bin/rm -f /dev/shm/decoder.txt 9 | ExecStopPost=-/bin/rm -f /dev/shm/decoder.txt 10 | ExecStart=/bin/bash -c "/usr/bin/fr24feed | sed -u -e 's/[0-9,-]* [0-9,:]* | //'" 11 | LimitNOFILE=256 12 | User=fr24 13 | Group=fr24 14 | PermissionsStartOnly=true 15 | SyslogIdentifier=fr24feed 16 | SendSIGHUP=yes 17 | TimeoutStopSec=5 18 | RestartSec=5 19 | StartLimitInterval=1 20 | StartLimitBurst=100 21 | 22 | [Install] 23 | WantedBy=multi-user.target 24 | 25 | -------------------------------------------------------------------------------- /inotify-debug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR 4 | 5 | if ! command -v inotifywait || ! command -v s6wrap; then 6 | apt update 7 | apt install --no-install-recommends -y inotify-tools gcc libc6-dev make git 8 | 9 | cd /tmp 10 | rm -rf /tmp/s6wrap 11 | git clone https://github.com/wiedehopf/s6wrap 12 | cd s6wrap 13 | make 14 | cp -f s6wrap /usr/local/bin/ 15 | fi 16 | 17 | pkill inotifywait || true 18 | rm -f /run/inotify.log 19 | 20 | echo 192000 > /proc/sys/fs/inotify/max_user_watches 21 | s6wrap --timestamps --args inotifywait -r -m /etc /opt /root /home /usr /lib /boot /var \ 22 | | grep --line-buffered -F -v -e OPEN -e NOWRITE -e ACCESS -e /exclude_dir1 -e /exclude_dir2 \ 23 | >/run/inotify.log 2>&1 & 24 | disown 25 | 26 | 27 | echo 28 | echo 29 | echo "to view writes, use: tail -f -n 200 /run/inotify.log" 30 | echo "to kill, use: pkill inotifywait" 31 | echo 32 | echo 33 | -------------------------------------------------------------------------------- /install-complete.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | renice 10 $$ 4 | clear 5 | echo "--------------" 6 | echo "Bundle install for dump1090-fa by wiedehopf" 7 | echo "--------------" 8 | 9 | 10 | bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/adsb-scripts/master/install-dump1090-fa.sh)" 11 | bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/adsb-scripts/master/dump1090-fa-autogain.sh)" 12 | bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/dump1090-retro-html/master/install.sh)" 13 | bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/tar1090/master/install.sh)" 14 | -------------------------------------------------------------------------------- /install-dump1090-fa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | 4 | set -e 5 | trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR 6 | renice 10 $$ 7 | 8 | if [ -f /boot/adsb-config.txt ]; then 9 | echo -------- 10 | echo "You are using the adsbx image, this setup script would mess up the configuration." 11 | echo -------- 12 | echo "Exiting." 13 | exit 1 14 | fi 15 | 16 | if grep -qs stretch /etc/os-release 17 | then 18 | repository="http://flightaware.com/adsb/piaware/files/packages/pool/piaware/p/piaware-support/piaware-repository_3.8.1~bpo9+1_all.deb" 19 | elif grep -qs buster /etc/os-release 20 | then 21 | repository="http://flightaware.com/adsb/piaware/files/packages/pool/piaware/p/piaware-support/piaware-repository_6.1_all.deb" 22 | else 23 | repository="https://www.flightaware.com/adsb/piaware/files/packages/pool/piaware/f/flightaware-apt-repository/flightaware-apt-repository_1.2_all.deb" 24 | fi 25 | 26 | function copyNoClobber() { 27 | if ! [[ -f "$2" ]]; then 28 | cp "$1" "$2" 29 | fi 30 | } 31 | 32 | if [[ -f /usr/lib/fr24/fr24feed_updater.sh ]]; then 33 | #fix readonly remount logic in fr24feed update script, doesn't do anything when fr24 is not installed 34 | mount -o remount,rw / &>/dev/null || true 35 | sed -i -e 's?$(mount | grep " on / " | grep rw)?{ mount | grep " on / " | grep rw; }?' /usr/lib/fr24/fr24feed_updater.sh &>/dev/null || true 36 | fi 37 | 38 | ipath=/usr/local/share/adsb-wiki 39 | mkdir -p $ipath 40 | 41 | cd /tmp 42 | wget --timeout=30 -q -O repository.deb $repository 43 | dpkg -i repository.deb 44 | apt-get update || true 45 | apt-get install --no-install-recommends --no-install-suggests --reinstall -y dump1090-fa 46 | 47 | if ! /usr/bin/dump1090-fa --help >/dev/null; then 48 | echo "Couldn't install dump1090-fa! (Maybe try again?)" 49 | exit 1 50 | fi 51 | 52 | udevadm control --reload-rules || true 53 | 54 | systemctl stop fr24feed &>/dev/null || true 55 | systemctl stop rb-feeder &>/dev/null || true 56 | 57 | if grep -qs -e '--device 0' /etc/default/readsb && { ! [[ -f /etc/default/dump1090-fa ]] || grep -qs -e '--device 0' /etc/default/dump1090-fa; }; then 58 | systemctl disable --now readsb &>/dev/null || true 59 | fi 60 | systemctl disable --now dump1090-mutability &>/dev/null || true 61 | systemctl disable --now dump1090 &>/dev/null || true 62 | 63 | rm -f /etc/lighttpd/conf-enabled/89-dump1090.conf 64 | rm -f /etc/lighttpd/conf-enabled/*readsb*.conf &>/dev/null 65 | 66 | # configure rbfeeder to use readsb 67 | 68 | if [[ -f /etc/rbfeeder.ini ]]; then 69 | copyNoClobber /etc/rbfeeder.ini /usr/local/share/adsb-wiki || true 70 | sed -i -e '/network_mode/d' -e '/\[network\]/d' -e '/mode=/d' -e '/external_port/d' -e '/external_host/d' /etc/rbfeeder.ini 71 | sed -i -e 's/\[client\]/\0\nnetwork_mode=true/' /etc/rbfeeder.ini 72 | cat >>/etc/rbfeeder.ini <<"EOF" 73 | [network] 74 | mode=beast 75 | external_port=30005 76 | external_host=127.0.0.1 77 | EOF 78 | pkill -9 rbfeeder || true 79 | systemctl restart rbfeeder &>/dev/null || true 80 | fi 81 | 82 | # configure fr24feed to use dump1090-fa 83 | 84 | if [ -f /etc/fr24feed.ini ] 85 | then 86 | chmod a+rw /etc/fr24feed.ini || true 87 | apt-get install -y dos2unix &>/dev/null && dos2unix /etc/fr24feed.ini &>/dev/null || true 88 | copyNoClobber /etc/fr24feed.ini /usr/local/share/adsb-wiki || true 89 | 90 | if ! grep -e 'host=' /etc/fr24feed.ini &>/dev/null; then echo 'host=' >> /etc/fr24feed.ini; fi 91 | if ! grep -e 'receiver=' /etc/fr24feed.ini &>/dev/null; then echo 'receiver=' >> /etc/fr24feed.ini; fi 92 | 93 | sed -i -e 's/receiver=.*/receiver="beast-tcp"/' -e 's/host=.*/host="127.0.0.1:30005"/' \ 94 | -e 's/mlat=.*/mlat="no"/' -e 's/bs=.*/bs="no"/' -e 's/raw=.*/raw="no"/' /etc/fr24feed.ini 95 | 96 | systemctl restart fr24feed &>/dev/null || true 97 | fi 98 | 99 | sed -i -e 's/--net-ro-interval 1/--net-ro-interval 0.1/' /etc/default/dump1090-fa || true 100 | 101 | lighty-enable-mod dump1090-fa || true 102 | lighty-enable-mod dump1090-fa-statcache || true 103 | 104 | mv -f /etc/lighttpd/conf-available/89-dump1090-fa.conf.dpkg-dist /etc/lighttpd/conf-available/89-dump1090-fa.conf &>/dev/null || true 105 | 106 | if (( $(cat /etc/lighttpd/conf-enabled/* | grep -c -E -e '^server.stat-cache-engine *\= *"disable"') > 1 )); then 107 | rm -f /etc/lighttpd/conf-enabled/88-dump1090-fa-statcache.conf 108 | fi 109 | 110 | systemctl daemon-reload 111 | systemctl restart lighttpd || true 112 | 113 | # script to change gain 114 | 115 | mkdir -p /usr/local/bin 116 | cat >/usr/local/bin/dump1090-fa-gain <<"EOF" 117 | #!/bin/bash 118 | gain=$(echo $1 | tr -cd '[:digit:].-') 119 | if [[ $gain == "" ]]; then echo "Error, invalid gain!"; exit 1; fi 120 | if [ -f /boot/piaware-config.txt ] 121 | then 122 | sudo piaware-config rtlsdr-gain $gain 123 | fi 124 | if ! grep gain /etc/default/dump1090-fa &>/dev/null; then sed -i -e 's/RECEIVER_OPTIONS="/RECEIVER_OPTIONS="--gain 49.6 /' /etc/default/dump1090-fa; fi 125 | sudo sed -i -E -e "s/--gain .?[0-9]*.?[0-9]* /--gain $gain /" /etc/default/dump1090-fa 126 | sudo systemctl restart dump1090-fa 127 | EOF 128 | chmod a+x /usr/local/bin/dump1090-fa-gain 129 | 130 | 131 | # set-location 132 | cat >/usr/local/bin/dump1090-fa-set-location <<"EOF" 133 | #!/bin/bash 134 | if [ -f /boot/piaware-config.txt ] 135 | then 136 | echo "Piaware sd-card image detected, location can only be set via your Flightaware ADS-B Statistics page!" 137 | exit 1 138 | fi 139 | if grep -qs /etc/default/dump1090-fa -e 'CONFIG_STYLE.*6'; then 140 | echo "dump1090-fa 6 config style not supported, just edit the file yourself!" 141 | echo "Support might be added in the future, in the meantime consider using readsb if you don't want to edit the config by hand:" 142 | echo "https://github.com/wiedehopf/adsb-scripts/wiki/Automatic-installation-for-readsb" 143 | exit 1 144 | fi 145 | 146 | lat=$(echo $1 | tr -cd '[:digit:].-') 147 | lon=$(echo $2 | tr -cd '[:digit:].-') 148 | 149 | if ! awk "BEGIN{ exit ($lat > 90) }" || ! awk "BEGIN{ exit ($lat < -90) }"; then 150 | echo 151 | echo "Invalid latitude: $lat" 152 | echo "Latitude must be between -90 and 90" 153 | echo 154 | echo "Example format for latitude: 51.528308" 155 | echo 156 | echo "Usage:" 157 | echo "dump1090-fa-set-location 51.52830 -0.38178" 158 | echo 159 | exit 1 160 | fi 161 | if ! awk "BEGIN{ exit ($lon > 180) }" || ! awk "BEGIN{ exit ($lon < -180) }"; then 162 | echo 163 | echo "Invalid longitude: $lon" 164 | echo "Longitude must be between -180 and 180" 165 | echo 166 | echo "Example format for latitude: -0.38178" 167 | echo 168 | echo "Usage:" 169 | echo "dump1090-fa-set-location 51.52830 -0.38178" 170 | echo 171 | exit 1 172 | fi 173 | 174 | echo 175 | echo "setting Latitude: $lat" 176 | echo "setting Longitude: $lon" 177 | echo 178 | if ! grep -e '--lon' /etc/default/dump1090-fa &>/dev/null; then sed -i -e 's/DECODER_OPTIONS="/DECODER_OPTIONS="--lon -0.38178 /' /etc/default/dump1090-fa; fi 179 | if ! grep -e '--lat' /etc/default/dump1090-fa &>/dev/null; then sed -i -e 's/DECODER_OPTIONS="/DECODER_OPTIONS="--lat 51.52830 /' /etc/default/dump1090-fa; fi 180 | sed -i -E -e "s/--lat .?[0-9]*.?[0-9]* /--lat $lat /" /etc/default/dump1090-fa 181 | sed -i -E -e "s/--lon .?[0-9]*.?[0-9]* /--lon $lon /" /etc/default/dump1090-fa 182 | systemctl restart dump1090-fa 183 | EOF 184 | chmod a+x /usr/local/bin/dump1090-fa-set-location 185 | 186 | 187 | echo -------------- 188 | systemctl restart dump1090-fa 189 | echo -------------- 190 | echo "All done!" 191 | 192 | -------------------------------------------------------------------------------- /libacars/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | set -e 4 | SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd)/$(basename "$0")" 5 | trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR 6 | renice 10 $$ 7 | 8 | cd /tmp 9 | 10 | repo="https://github.com/wiedehopf/adsb-scripts" 11 | ipath=/usr/local/share/adsb-scripts 12 | stuff="git cmake zlib1g-dev libjansson-dev" 13 | branch="master" 14 | 15 | if [[ -n $1 ]]; then 16 | branch="$1" 17 | fi 18 | 19 | apt install -y $stuff || apt update && apt install -y $stuff || true 20 | 21 | mkdir -p $ipath 22 | 23 | function getGIT() { 24 | # getGIT $REPO $BRANCH $TARGET (directory) 25 | if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then echo "getGIT wrong usage, check your script or tell the author!" 1>&2; return 1; fi 26 | REPO="$1"; BRANCH="$2"; TARGET="$3"; pushd . 27 | if cd "$TARGET" &>/dev/null && git fetch --depth 1 origin "$BRANCH" && git reset --hard FETCH_HEAD; then popd; return 0; fi 28 | if ! cd /tmp || ! rm -rf "$TARGET"; then popd; return 1; fi 29 | if git clone --depth 1 --single-branch --branch "$2" "$1" "$3"; then popd; return 0; fi 30 | popd; return 1; 31 | } 32 | 33 | # get adsb-scripts repo 34 | getGIT "$repo" master "$ipath/git" 35 | 36 | 37 | cd "$ipath/git/libacars" 38 | 39 | GIT="$ipath/libacars-git" 40 | getGIT https://github.com/szpajder/libacars "$branch" "$GIT" 41 | 42 | cd "$GIT" 43 | 44 | VERSION="$(git rev-parse HEAD)_with-jansson" 45 | 46 | if grep -qs -e "$VERSION" "$ipath/libacars-installed"; then 47 | echo "---------------------------------------------" 48 | echo "skipping libacars install - already latest version" 49 | echo "to force reinstall: sudo rm -f $ipath/libacars-installed; sudo bash $ipath/git/libacars/install.sh" 50 | echo "---------------------------------------------" 51 | exit 0 52 | fi 53 | 54 | rm -rf build 55 | mkdir build 56 | cd build 57 | 58 | cmake -DCMAKE_BUILD_TYPE=Release .. 59 | 60 | make -j2 61 | 62 | make install 63 | 64 | ldconfig 65 | 66 | echo "$VERSION" > "$ipath/libacars-installed" 67 | 68 | echo "-----------------------------------" 69 | echo "$SCRIPT_PATH completed successfully" 70 | echo "-----------------------------------" 71 | -------------------------------------------------------------------------------- /librtlsdr.so.0.6git: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiedehopf/adsb-scripts/4375ae0c24318064ff179e4314929c0dc55808cf/librtlsdr.so.0.6git -------------------------------------------------------------------------------- /osm_tiles_offline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | 4 | set -e 5 | trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR 6 | 7 | IPATH=/usr/local/share/osm_tiles_offline 8 | 9 | mkdir -p "$IPATH" 10 | cd "$IPATH" 11 | 12 | F=osm_tiles_0_9.tar.gz 13 | wget -O $F https://github.com/wiedehopf/adsb-scripts/releases/download/osm2022/$F 14 | 15 | echo Extracting, this will take a bit ..... 16 | tar --overwrite -x -f $F 17 | rm -f $F 18 | 19 | echo ................................. done 20 | -------------------------------------------------------------------------------- /osm_tiles_offline_10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | 4 | set -e 5 | trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR 6 | 7 | IPATH=/usr/local/share/osm_tiles_offline 8 | 9 | mkdir -p "$IPATH" 10 | cd "$IPATH" 11 | 12 | F=osm_tiles_10.tar.gz 13 | wget -O $F https://github.com/wiedehopf/adsb-scripts/releases/download/osm2022/$F 14 | 15 | echo Extracting, this will take a bit ..... 16 | tar --overwrite -x -f $F 17 | rm -f $F 18 | 19 | echo ................................. done 20 | -------------------------------------------------------------------------------- /osmocom-rtl-sdr.rules: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012-2013 Osmocom rtl-sdr project 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | # 17 | 18 | # original RTL2832U vid/pid (hama nano, for example) 19 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2832", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 20 | 21 | # RTL2832U OEM vid/pid, e.g. ezcap EzTV668 (E4000), Newsky TV28T (E4000/R820T) etc. 22 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 23 | 24 | # DigitalNow Quad DVB-T PCI-E card (4x FC0012?) 25 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0413", ATTRS{idProduct}=="6680", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 26 | 27 | # Leadtek WinFast DTV Dongle mini D (FC0012) 28 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0413", ATTRS{idProduct}=="6f0f", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 29 | 30 | # Genius TVGo DVB-T03 USB dongle (Ver. B) 31 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0458", ATTRS{idProduct}=="707f", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 32 | 33 | # Terratec Cinergy T Stick Black (rev 1) (FC0012) 34 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00a9", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 35 | 36 | # Terratec NOXON rev 1 (FC0013) 37 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00b3", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 38 | 39 | # Terratec Deutschlandradio DAB Stick (FC0013) 40 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00b4", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 41 | 42 | # Terratec NOXON DAB Stick - Radio Energy (FC0013) 43 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00b5", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 44 | 45 | # Terratec Media Broadcast DAB Stick (FC0013) 46 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00b7", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 47 | 48 | # Terratec BR DAB Stick (FC0013) 49 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00b8", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 50 | 51 | # Terratec WDR DAB Stick (FC0013) 52 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00b9", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 53 | 54 | # Terratec MuellerVerlag DAB Stick (FC0013) 55 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00c0", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 56 | 57 | # Terratec Fraunhofer DAB Stick (FC0013) 58 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00c6", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 59 | 60 | # Terratec Cinergy T Stick RC (Rev.3) (E4000) 61 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00d3", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 62 | 63 | # Terratec T Stick PLUS (E4000) 64 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00d7", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 65 | 66 | # Terratec NOXON rev 2 (E4000) 67 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ccd", ATTRS{idProduct}=="00e0", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 68 | 69 | # PixelView PV-DT235U(RN) (FC0012) 70 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1554", ATTRS{idProduct}=="5020", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 71 | 72 | # Astrometa DVB-T/DVB-T2 (R828D) 73 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="15f4", ATTRS{idProduct}=="0131", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 74 | 75 | # HanfTek DAB+FM+DVB-T 76 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="15f4", ATTRS{idProduct}=="0133", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 77 | 78 | # Compro Videomate U620F (E4000) 79 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="185b", ATTRS{idProduct}=="0620", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 80 | 81 | # Compro Videomate U650F (E4000) 82 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="185b", ATTRS{idProduct}=="0650", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 83 | 84 | # Compro Videomate U680F (E4000) 85 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="185b", ATTRS{idProduct}=="0680", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 86 | 87 | # GIGABYTE GT-U7300 (FC0012) 88 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b80", ATTRS{idProduct}=="d393", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 89 | 90 | # DIKOM USB-DVBT HD 91 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b80", ATTRS{idProduct}=="d394", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 92 | 93 | # Peak 102569AGPK (FC0012) 94 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b80", ATTRS{idProduct}=="d395", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 95 | 96 | # KWorld KW-UB450-T USB DVB-T Pico TV (TUA9001) 97 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b80", ATTRS{idProduct}=="d397", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 98 | 99 | # Zaapa ZT-MINDVBZP (FC0012) 100 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b80", ATTRS{idProduct}=="d398", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 101 | 102 | # SVEON STV20 DVB-T USB & FM (FC0012) 103 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b80", ATTRS{idProduct}=="d39d", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 104 | 105 | # Twintech UT-40 (FC0013) 106 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b80", ATTRS{idProduct}=="d3a4", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 107 | 108 | # ASUS U3100MINI_PLUS_V2 (FC0013) 109 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b80", ATTRS{idProduct}=="d3a8", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 110 | 111 | # SVEON STV27 DVB-T USB & FM (FC0013) 112 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b80", ATTRS{idProduct}=="d3af", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 113 | 114 | # SVEON STV21 DVB-T USB & FM 115 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b80", ATTRS{idProduct}=="d3b0", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 116 | 117 | # Dexatek DK DVB-T Dongle (Logilink VG0002A) (FC2580) 118 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1d19", ATTRS{idProduct}=="1101", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 119 | 120 | # Dexatek DK DVB-T Dongle (MSI DigiVox mini II V3.0) 121 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1d19", ATTRS{idProduct}=="1102", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 122 | 123 | # Dexatek DK 5217 DVB-T Dongle (FC2580) 124 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1d19", ATTRS{idProduct}=="1103", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 125 | 126 | # MSI DigiVox Micro HD (FC2580) 127 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1d19", ATTRS{idProduct}=="1104", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 128 | 129 | # Sweex DVB-T USB (FC0012) 130 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1f4d", ATTRS{idProduct}=="a803", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 131 | 132 | # GTek T803 (FC0012) 133 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1f4d", ATTRS{idProduct}=="b803", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 134 | 135 | # Lifeview LV5TDeluxe (FC0012) 136 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1f4d", ATTRS{idProduct}=="c803", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 137 | 138 | # MyGica TD312 (FC0012) 139 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1f4d", ATTRS{idProduct}=="d286", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 140 | 141 | # PROlectrix DV107669 (FC0012) 142 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1f4d", ATTRS{idProduct}=="d803", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev" 143 | -------------------------------------------------------------------------------- /pingfail-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | 4 | repo="https://github.com/wiedehopf/adsb-scripts" 5 | ipath=/usr/local/share/adsb-scripts 6 | 7 | if ! command -v git &>/dev/null 8 | then 9 | apt-get update 10 | if ! apt-get install -y git 11 | then 12 | echo "Failed to install git, exiting!" 13 | exit 1 14 | fi 15 | fi 16 | 17 | mkdir -p $ipath 18 | 19 | if git clone --depth 1 $repo $ipath/git 2>/dev/null || cd $ipath/git 20 | then 21 | cd $ipath/git 22 | git checkout -f master 23 | git fetch 24 | git reset --hard origin/master 25 | else 26 | echo "Download failed" 27 | exit 1 28 | fi 29 | 30 | cp pingfail.sh $ipath 31 | cp pingfail.service /lib/systemd/system 32 | 33 | systemctl enable pingfail 34 | systemctl restart pingfail 35 | -------------------------------------------------------------------------------- /pingfail.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=pingfail - reboot when there is no internet 3 | Documentation=https://github.com/wiedehopf/adsb-scripts/wiki/pingfail 4 | Wants=network.target 5 | After=network.target 6 | 7 | [Service] 8 | ExecStart=/bin/bash /usr/local/share/adsb-scripts/pingfail.sh 9 | Type=simple 10 | Restart=always 11 | 12 | [Install] 13 | WantedBy=default.target 14 | -------------------------------------------------------------------------------- /pingfail.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | 4 | trap "exit" INT TERM 5 | trap "kill 0" EXIT 6 | 7 | TEST1="google.com" 8 | TEST2="akamai.com" 9 | FAIL="no" 10 | 11 | while sleep 300 12 | do 13 | if ping $TEST1 -c1 -w5 >/dev/null || ping $TEST2 -c1 -w5 >/dev/null 14 | then 15 | FAIL="no" 16 | elif [[ "$FAIL" == yes ]] 17 | then 18 | if ! ping $TEST1 -c5 -w20 >/dev/null && ! ping $TEST2 -c5 -w20 >/dev/null 19 | then 20 | echo "$(date): Rebooting, could reach neither $TEST1 nor $TEST2" | tee -a /var/log/pingfail 21 | mkdir -p /run/systemd/system/reboot.target.d/ 22 | cat > /run/systemd/system/reboot.target.d/fastreboot.conf <<"EOF" 23 | [Unit] 24 | JobTimeoutSec=60 25 | JobTimeoutAction=reboot-force 26 | EOF 27 | systemctl daemon-reload 28 | sync 29 | reboot 30 | fi 31 | FAIL="no" 32 | else 33 | FAIL="yes" 34 | fi 35 | done 36 | -------------------------------------------------------------------------------- /readsb-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | 4 | if [ "$(id -u)" != "0" ]; then 5 | echo -e "\033[33m" 6 | echo "This script must be ran using sudo or as root." 7 | echo -e "\033[37m" 8 | exit 1 9 | fi 10 | 11 | set -e 12 | trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR 13 | renice 10 $$ 14 | 15 | if [ -f /boot/piaware-config.txt ]; then 16 | echo -------- 17 | echo "You are using the piaware image, this setup script would mess up the configuration." 18 | echo -------- 19 | echo "Exiting." 20 | exit 1 21 | fi 22 | 23 | BRANCH="stale" 24 | if grep -E 'wheezy|jessie' /etc/os-release -qs; then 25 | BRANCH="jessie" 26 | fi 27 | 28 | for arg in "$@" 29 | do 30 | case "$arg" in 31 | tag=*) 32 | BRANCH=$(cut -d= -f2 <<< "$arg") 33 | ;; 34 | push-30004) 35 | push_30004=yes 36 | ;; 37 | binary-only) 38 | BINARY_ONLY=yes 39 | ;; 40 | no-tar1090) 41 | NO_TAR1090=yes 42 | ;; 43 | sid) 44 | BRANCH="sid" 45 | ;; 46 | *) 47 | MAKE_ARGS=yes 48 | ;; 49 | esac 50 | done 51 | 52 | function copyNoClobber() { 53 | if ! [[ -f "$2" ]]; then 54 | cp "$1" "$2" 55 | fi 56 | } 57 | 58 | repository="https://github.com/wiedehopf/readsb.git" 59 | 60 | 61 | if [[ -n "$push_30004" ]]; then 62 | cat >/etc/default/readsb <<"EOF" 63 | # readsb configuration 64 | # This is sourced by /etc/systemd/system/default.target.wants/readsb.service as 65 | # daemon startup configuration. 66 | 67 | RECEIVER_OPTIONS="--device 0 --device-type rtlsdr --gain -10 --ppm 0" 68 | DECODER_OPTIONS="--max-range 450 --write-json-every 1 --net-connector 127.0.0.1,30004,beast_out" 69 | NET_OPTIONS="--net --net-heartbeat 60 --net-ro-size 1280 --net-ro-interval 0.05 --net-ri-port 20001 --net-ro-port 20002 --net-sbs-port 20003 --net-bi-port 20004,20104 --net-bo-port 20005" 70 | JSON_OPTIONS="--json-location-accuracy 2 --range-outline-hours 24" 71 | EOF 72 | fi 73 | 74 | if [[ -f /usr/lib/fr24/fr24feed_updater.sh ]]; then 75 | #fix readonly remount logic in fr24feed update script, doesn't do anything when fr24 is not installed 76 | mount -o remount,rw / &>/dev/null || true 77 | sed -i -e 's?$(mount | grep " on / " | grep rw)?{ mount | grep " on / " | grep rw; }?' /usr/lib/fr24/fr24feed_updater.sh &>/dev/null || true 78 | fi 79 | 80 | # blacklist kernel driver as on ancient systems 81 | if grep -E 'wheezy|jessie' /etc/os-release -qs; then 82 | echo -e 'blacklist rtl2832\nblacklist dvb_usb_rtl28xxu\n' > /etc/modprobe.d/blacklist-rtl-sdr.conf 83 | rmmod rtl2832 &>/dev/null || true 84 | rmmod dvb_usb_rtl28xxu &>/dev/null || true 85 | fi 86 | 87 | ipath=/usr/local/share/adsb-wiki/readsb-install 88 | mkdir -p $ipath 89 | 90 | if grep -E 'wheezy|jessie' /etc/os-release -qs; then 91 | # make sure the rtl-sdr rules are present on ancient systems 92 | wget -O /tmp/rtl-sdr.rules https://raw.githubusercontent.com/wiedehopf/adsb-scripts/master/osmocom-rtl-sdr.rules 93 | cp /tmp/rtl-sdr.rules /etc/udev/rules.d/ 94 | fi 95 | 96 | function aptInstall() { 97 | if ! DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests "$@" &>/dev/null; then 98 | apt-get update 99 | DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests "$@" 100 | fi 101 | } 102 | 103 | if command -v apt &>/dev/null; then 104 | packages=(git gcc make libusb-1.0-0-dev ncurses-dev ncurses-bin zlib1g-dev zlib1g pkg-config libc6-dev) 105 | if ! grep -E 'wheezy|jessie' /etc/os-release -qs; then 106 | packages+=(libzstd-dev libzstd1) 107 | fi 108 | if ! command -v nginx &>/dev/null && [[ -z "$NO_TAR1090" ]] ; then 109 | packages+=(lighttpd) 110 | fi 111 | packages+=(librtlsdr-dev) 112 | if grep -qs -i -e 'ubuntu' /etc/os-release; then 113 | aptInstall librtlsdr0 || aptInstall librtlsdr2 114 | else 115 | packages+=(librtlsdr0) 116 | fi 117 | aptInstall "${packages[@]}" 118 | fi 119 | 120 | udevadm control --reload-rules || true 121 | udevadm trigger || true 122 | 123 | function getGIT() { 124 | # getGIT $REPO $BRANCH $TARGET-DIR 125 | if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then 126 | echo "getGIT wrong usage, check your script or tell the author!" 1>&2 127 | return 1 128 | fi 129 | if ! cd "$3" &>/dev/null || ! git fetch --depth 2 origin "$2" || ! git reset --hard FETCH_HEAD; then 130 | if ! rm -rf "$3" || ! git clone --depth 2 --single-branch --branch "$2" "$1" "$3"; then 131 | return 1 132 | fi 133 | fi 134 | return 0 135 | } 136 | if ! getGIT "$repository" "$BRANCH" "$ipath/git" 137 | then 138 | echo "Unable to git clone the repository" 139 | exit 1 140 | fi 141 | 142 | rm -rf "$ipath"/readsb*.deb 143 | cd "$ipath/git" 144 | 145 | make clean 146 | THREADS=$(( $(grep -c ^processor /proc/cpuinfo) - 1 )) 147 | THREADS=$(( THREADS > 0 ? THREADS : 1 )) 148 | CFLAGS="-O2 -march=native -mtune=native" 149 | 150 | # disable unaligned access for arm 32bit ... 151 | if uname -m | grep -qs -e arm -e aarch64 && gcc -mno-unaligned-access hello.c -o /dev/null &>/dev/null; then 152 | CFLAGS+=" -mno-unaligned-access" 153 | fi 154 | 155 | if [[ $1 == "sanitize" ]]; then 156 | CFLAGS+="-fsanitize=address -static-libasan" 157 | if ! make "-j${THREADS}" RTLSDR=yes OPTIMIZE="$CFLAGS"; then 158 | if grep -qs /etc/os-release 'bookworm'; then aptInstall libasan8; 159 | elif grep -qs /etc/os-release 'bullseye'; then aptInstall libasan6; 160 | elif grep -qs /etc/os-release 'buster'; then aptInstall libasan5; 161 | fi 162 | make "-j${THREADS}" RTLSDR=yes OPTIMIZE="$CFLAGS" 163 | fi 164 | else 165 | if [[ -n "$MAKE_ARGS" ]]; then 166 | make "-j${THREADS}" RTLSDR=yes OPTIMIZE="$CFLAGS" "$@" 167 | else 168 | make "-j${THREADS}" RTLSDR=yes OPTIMIZE="$CFLAGS" 169 | fi 170 | fi 171 | 172 | 173 | rm -f /usr/bin/readsb /usr/bin/viewadsb 174 | cp -f readsb /usr/bin/readsb 175 | cp -f viewadsb /usr/bin/viewadsb 176 | 177 | cp -f debian/readsb.service /lib/systemd/system/readsb.service 178 | copyNoClobber debian/readsb.default /etc/default/readsb 179 | 180 | if [[ -n "$BINARY_ONLY" ]]; then 181 | systemctl restart readsb 182 | echo /usr/bin/readsb has been replaced with an updated version 183 | exit 0 184 | fi 185 | 186 | if ! id -u readsb &>/dev/null 187 | then 188 | adduser --system --no-create-home readsb 189 | adduser readsb plugdev # SDR access (via udev rules) 190 | adduser readsb dialout # serial access 191 | fi 192 | 193 | apt remove -y dump1090-fa &>/dev/null || true 194 | apt remove -y dump1090-mutability &>/dev/null || true 195 | apt remove -y dump1090 &>/dev/null || true 196 | 197 | rm -f /etc/lighttpd/conf-enabled/89-dump1090.conf 198 | 199 | # configure rbfeeder to use readsb 200 | 201 | if [[ -f /etc/rbfeeder.ini ]]; then 202 | systemctl stop rb-feeder &>/dev/null || true 203 | copyNoClobber /etc/rbfeeder.ini /usr/local/share/adsb-wiki || true 204 | sed -i -e '/network_mode/d' -e '/\[network\]/d' -e '/mode=/d' -e '/external_port/d' -e '/external_host/d' /etc/rbfeeder.ini 205 | sed -i -e 's/\[client\]/\0\nnetwork_mode=true/' /etc/rbfeeder.ini 206 | cat >>/etc/rbfeeder.ini <<"EOF" 207 | [network] 208 | mode=beast 209 | external_port=30005 210 | external_host=127.0.0.1 211 | EOF 212 | pkill -9 rbfeeder || true 213 | systemctl restart rbfeeder &>/dev/null || true 214 | fi 215 | 216 | # configure fr24feed to use readsb 217 | 218 | if [ -f /etc/fr24feed.ini ] 219 | then 220 | systemctl stop fr24feed &>/dev/null || true 221 | chmod a+rw /etc/fr24feed.ini || true 222 | apt-get install -y dos2unix &>/dev/null && dos2unix /etc/fr24feed.ini &>/dev/null || true 223 | copyNoClobber /etc/fr24feed.ini /usr/local/share/adsb-wiki || true 224 | 225 | if ! grep -e 'host=' /etc/fr24feed.ini &>/dev/null; then echo 'host=' >> /etc/fr24feed.ini; fi 226 | if ! grep -e 'receiver=' /etc/fr24feed.ini &>/dev/null; then echo 'receiver=' >> /etc/fr24feed.ini; fi 227 | 228 | sed -i -e 's/receiver=.*/receiver="beast-tcp"/' -e 's/host=.*/host="127.0.0.1:30005"/' \ 229 | -e 's/mlat=.*/mlat="no"/' -e 's/bs=.*/bs="no"/' -e 's/raw=.*/raw="no"/' /etc/fr24feed.ini 230 | 231 | systemctl restart fr24feed &>/dev/null || true 232 | fi 233 | 234 | systemctl enable readsb 235 | systemctl restart readsb || true 236 | 237 | # script to change gain 238 | 239 | mkdir -p /usr/local/bin 240 | cat >/usr/local/bin/readsb-gain <<"EOF" 241 | #!/bin/bash 242 | validre='^([^ ]*)$' 243 | gain="$1" 244 | if ! [[ $gain =~ $validre ]] ; then echo "Error, invalid gain!"; exit 1; fi 245 | if ! grep gain /etc/default/readsb &>/dev/null; then sudo sed -i -e 's/RECEIVER_OPTIONS="/RECEIVER_OPTIONS="--gain 49.6 /' /etc/default/readsb; fi 246 | sudo sed -i -E -e "s/--gain[ =][^ \"]*/--gain $gain/" /etc/default/readsb 247 | echo "$gain" | sudo tee /run/readsb/setGain || sudo systemctl restart readsb 248 | EOF 249 | chmod a+x /usr/local/bin/readsb-gain 250 | 251 | 252 | # set-location 253 | cat >/usr/local/bin/readsb-set-location <<"EOF" 254 | #!/bin/bash 255 | 256 | lat=$(echo $1 | tr -cd '[:digit:].-') 257 | lon=$(echo $2 | tr -cd '[:digit:].-') 258 | 259 | if ! awk "BEGIN{ exit ($lat > 90) }" || ! awk "BEGIN{ exit ($lat < -90) }"; then 260 | echo 261 | echo "Invalid latitude: $lat" 262 | echo "Latitude must be between -90 and 90" 263 | echo 264 | echo "Example format for latitude: 51.528308" 265 | echo 266 | echo "Usage:" 267 | echo "readsb-set-location 51.52830 -0.38178" 268 | echo 269 | exit 1 270 | fi 271 | if ! awk "BEGIN{ exit ($lon > 180) }" || ! awk "BEGIN{ exit ($lon < -180) }"; then 272 | echo 273 | echo "Invalid longitude: $lon" 274 | echo "Longitude must be between -180 and 180" 275 | echo 276 | echo "Example format for latitude: -0.38178" 277 | echo 278 | echo "Usage:" 279 | echo "readsb-set-location 51.52830 -0.38178" 280 | echo 281 | exit 1 282 | fi 283 | 284 | echo 285 | echo "setting Latitude: $lat" 286 | echo "setting Longitude: $lon" 287 | echo 288 | if ! grep -e '--lon' /etc/default/readsb &>/dev/null; then sed -i -e 's/DECODER_OPTIONS="/DECODER_OPTIONS="--lon -0.38178 /' /etc/default/readsb; fi 289 | if ! grep -e '--lat' /etc/default/readsb &>/dev/null; then sed -i -e 's/DECODER_OPTIONS="/DECODER_OPTIONS="--lat 51.52830 /' /etc/default/readsb; fi 290 | sed -i -E -e "s/--lat .?[0-9]*.?[0-9]* /--lat $lat /" /etc/default/readsb 291 | sed -i -E -e "s/--lon .?[0-9]*.?[0-9]* /--lon $lon /" /etc/default/readsb 292 | systemctl restart readsb 293 | EOF 294 | chmod a+x /usr/local/bin/readsb-set-location 295 | 296 | 297 | echo -------------- 298 | cd "$ipath" 299 | 300 | if [[ -z "$NO_TAR1090" ]] ; then 301 | wget -O tar1090-install.sh https://raw.githubusercontent.com/wiedehopf/tar1090/master/install.sh 302 | bash tar1090-install.sh /run/readsb 303 | fi 304 | 305 | if ! systemctl show readsb | grep 'ExecMainStatus=0' -qs; then 306 | echo -------------- 307 | echo -------------- 308 | journalctl -u readsb | tail -n30 | tee journal.log 309 | echo -------------- 310 | echo -------------- 311 | if grep -qs -e 'Permission denied' journal.log; then 312 | echo "ERROR: readsb permission issue, please perform a reboot using this command: sudo reboot" 313 | echo "--------------" 314 | echo "After the reboot, the webinterface will be available at http://$(ip route get 1.2.3.4 | grep -m1 -o -P 'src \K[0-9,.]*')/tar1090" 315 | else 316 | echo "ERROR: readsb service didn't start." 317 | echo " common issues: SDR not plugged in." 318 | echo " the webinterface will show an error until readsb is running!" 319 | echo " If you can't fix the issue:" 320 | echo " Open a github issue or contact wiedehopf on discord (https://discord.gg/DxU4VG37JS) and post the above 30 lines of log!" 321 | echo -------------- 322 | fi 323 | else 324 | echo "Don't forget to set your location using decimal latitude and longitude:" 325 | echo 326 | if echo $PATH | grep -qs '/usr/local/bin'; then 327 | echo "sudo readsb-set-location 50.12344 10.23429" 328 | else 329 | echo "sudo /usr/local/bin/readsb-set-location 50.12344 10.23429" 330 | fi 331 | echo 332 | fi 333 | -------------------------------------------------------------------------------- /rtl_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | if ! dpkg -s rtl-sdr 2>/dev/null | grep 'Status.*installed' &>/dev/null 5 | then 6 | if ! apt-get install --no-install-recommends --no-install-suggests --reinstall -y rtl-sdr 7 | then 8 | echo "Couldn't install rtl-sdr!" 9 | exit 1 10 | fi 11 | fi 12 | 13 | stop="piaware dump1090-fa dump1090-mutability dump1090 dump978-fa readsb" 14 | 15 | systemctl stop fr24feed &>/dev/null 16 | 17 | 18 | if pgrep -a dump1090 || pgrep -a dump978 || pgrep -a readsb 19 | then 20 | restart=yes 21 | for i in $stop 22 | do 23 | systemctl stop $i 2>/dev/null 24 | done 25 | pkill -9 dump1090 26 | pkill -9 readsb 27 | for i in $stop 28 | do 29 | systemctl stop $i 2>/dev/null 30 | done 31 | pkill -9 dump1090 32 | pkill -9 readsb 33 | sleep 1 34 | fi 35 | 36 | if pgrep -l dump1090 || pgrep -l readsb 37 | then 38 | echo "dump1090 is still running, can't test the rtl-sdr receiver, please reboot and try again!" 39 | for i in $stop 40 | do 41 | systemctl restart $i 2>/dev/null 42 | done 43 | systemctl restart fr24feed &>/dev/null 44 | exit 1 45 | fi 46 | 47 | 48 | echo "-----" 49 | echo "Lost samples in the first 2 seconds after starting the test are common and not a problem!" 50 | echo "Starting 30 second rtl_test, standby!" 51 | echo "-----" 52 | 53 | timeout 30 rtl_test -s 2400000 54 | 55 | echo "-------" 56 | echo "Test finished!" 57 | echo "More than 2 lost samples per million or other errors probably mean the receiver isn't working correctly." 58 | echo "Try another power supply before condemning the receiver though!" 59 | echo "-------" 60 | 61 | systemctl restart fr24feed &>/dev/null 62 | 63 | if [[ $restart == yes ]] 64 | then 65 | for i in $stop 66 | do 67 | systemctl restart $i 2>/dev/null 68 | done 69 | fi 70 | 71 | 72 | if dmesg --ctime | grep voltage 73 | then 74 | echo "-------" 75 | dmesg --ctime | grep voltage | tail -n15 76 | echo "-------" 77 | echo "Your power supply is not adequate, consider the Official Raspberry Pi power supply." 78 | echo "Any constant voltage supply with 5.1 to 5.2 Volts and 2.5A capability is also a good choice." 79 | echo "Inadequate power supplies can lead to many different problems!" 80 | echo "-------" 81 | else 82 | echo "-------" 83 | echo "No undervoltage detected, looking fine!" 84 | echo "If the dongle is not directly plugged into the Raspberry Pi, lack of power/voltage could still be an issue." 85 | echo "Even without detected undervoltage a better power supply can often improve reception!" 86 | echo "For optimum performance i would recommend the Official Raspberry Pi power supply." 87 | echo "-------" 88 | fi 89 | -------------------------------------------------------------------------------- /simple-storage-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # this needs to run as root 5 | if [ "$(id -u)" != "0" ] ; then 6 | echo "this command requires superuser privileges - please run as sudo bash $0" 7 | exit 1 8 | fi 9 | 10 | for i in {1..8}; do 11 | dd if=/dev/urandom of=/run/testFile bs=1M count=25 status=none 12 | cp /run/testFile /tmp 13 | sync 14 | echo 3 > /proc/sys/vm/drop_caches 15 | if ! diff -q -s /run/testFile /tmp/testFile; then 16 | echo "------------------------------------------------------" 17 | echo "TEST FAILED! Please replace storage medium!" 18 | echo "------------------------------------------------------" 19 | exit 1 20 | fi 21 | done 22 | echo "------------------------------------------------------" 23 | echo "Test completed OK! Storage probably fine :)" 24 | echo "------------------------------------------------------" 25 | -------------------------------------------------------------------------------- /throttled.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | if ! command -v vcgencmd &>/dev/null 5 | then 6 | echo ------- 7 | echo "Command vcgencmd not found, can't check for throttling!" 8 | echo "Exiting." 9 | echo ------- 10 | exit 1 11 | fi 12 | 13 | #Flag Bits 14 | UNDERVOLTED=0x1 15 | CAPPED=0x2 16 | THROTTLED=0x4 17 | SOFT_TEMPLIMIT=0x8 18 | HAS_UNDERVOLTED=0x10000 19 | HAS_CAPPED=0x20000 20 | HAS_THROTTLED=0x40000 21 | HAS_SOFT_TEMPLIMIT=0x80000 22 | 23 | 24 | #Text Colors 25 | GREEN=`tput setaf 2` 26 | RED=`tput setaf 1` 27 | NC=`tput sgr0` 28 | 29 | #Output Strings 30 | GOOD="${GREEN}NO${NC}" 31 | BAD="${RED}YES${NC}" 32 | 33 | #Get Status, extract hex 34 | STATUS=$(vcgencmd get_throttled) 35 | STATUS=${STATUS#*=} 36 | 37 | echo -n "Status: " 38 | (($STATUS!=0)) && echo "${RED}${STATUS}${NC}" || echo "${GREEN}${STATUS}${NC}" 39 | 40 | echo "Undervolted:" 41 | echo -n " Now: " 42 | ((($STATUS&UNDERVOLTED)!=0)) && echo "${BAD}" || echo "${GOOD}" 43 | echo -n " Run: " 44 | ((($STATUS&HAS_UNDERVOLTED)!=0)) && echo "${BAD}" || echo "${GOOD}" 45 | 46 | echo "Throttled:" 47 | echo -n " Now: " 48 | ((($STATUS&THROTTLED)!=0)) && echo "${BAD}" || echo "${GOOD}" 49 | echo -n " Run: " 50 | ((($STATUS&HAS_THROTTLED)!=0)) && echo "${BAD}" || echo "${GOOD}" 51 | 52 | echo "Frequency Capped:" 53 | echo -n " Now: " 54 | ((($STATUS&CAPPED)!=0)) && echo "${BAD}" || echo "${GOOD}" 55 | echo -n " Run: " 56 | ((($STATUS&HAS_CAPPED)!=0)) && echo "${BAD}" || echo "${GOOD}" 57 | 58 | echo "Softlimit:" 59 | echo -n " Now: " 60 | ((($STATUS&SOFT_TEMPLIMIT)!=0)) && echo "${BAD}" || echo "${GOOD}" 61 | echo -n " Run: " 62 | ((($STATUS&HAS_SOFT_TEMPLIMIT)!=0)) && echo "${BAD}" || echo "${GOOD}" 63 | -------------------------------------------------------------------------------- /uninstall-complete.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/adsb-scripts/master/uninstall-dump1090-fa.sh)" 4 | bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/adsb-scripts/master/uninstall-dump1090-fa-autogain.sh)" 5 | bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/dump1090-retro-html/master/uninstall.sh)" 6 | bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/tar1090/master/uninstall.sh)" 7 | -------------------------------------------------------------------------------- /uninstall-dump1090-fa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ipath=/usr/local/share/adsb-wiki 4 | 5 | systemctl stop fr24feed 6 | 7 | apt-get remove -y dump1090-fa 8 | apt-get purge -y dump1090-fa 9 | rm -f /etc/lighttpd/conf-enabled/89-dump1090-fa.conf 10 | rm -f /etc/lighttpd/conf-enabled/88-dump1090-fa-statcache.conf 11 | 12 | rm -f /usr/local/bin/dump1090-fa-gain 13 | rm -f /usr/local/bin/dump1090-fa-set-location 14 | 15 | echo "Restoring old fr24feed settings" 16 | mv $ipath/fr24feed.ini /etc/fr24feed.ini 17 | mv $ipath/89-dump1090.conf /etc/lighttpd/conf-enabled 18 | 19 | echo "This might take a moment, give it 5 minutes please." 20 | bash /usr/lib/fr24/install_dump1090.sh 21 | 22 | 23 | systemctl daemon-reload 24 | systemctl restart fr24feed 25 | systemctl restart lighttpd 26 | 27 | 28 | echo -------------- 29 | echo "install-dump1090-fa: Uninstall complete!" 30 | -------------------------------------------------------------------------------- /vdlm2dec/default: -------------------------------------------------------------------------------- 1 | OPTIONS0= -v -J -G -E -U -j feed.acars.io:5555 2 | 3 | # station name for acars.io: 4 | OPTIONS1= -i XX-YYYYZ 5 | 6 | # gain for rtl-sdr, 0 to 496 (value is in tenth, so 200 will be 20.0) 7 | OPTIONS2= -g 439 8 | 9 | # to have the messages written to disk instead of the journal, uncomment the following line: 10 | # OPTIONS4= -l /var/tmp/vdlm2dec 11 | 12 | # rtl-sdr device id or serial: 13 | OPTIONS7= -r 0 14 | 15 | # frequencies scanned: 16 | OPTIONS8= 136.650 136.800 136.975 17 | 18 | -------------------------------------------------------------------------------- /vdlm2dec/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | umask 022 3 | set -e 4 | SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd)/$(basename "$0")" 5 | trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR 6 | renice 10 $$ 7 | 8 | cd /tmp 9 | 10 | repo="https://github.com/wiedehopf/adsb-scripts" 11 | ipath=/usr/local/share/adsb-scripts 12 | stuff="git cmake libusb-1.0-0-dev librtlsdr-dev librtlsdr0" 13 | branch="master" 14 | 15 | if [[ -n $1 ]]; then 16 | branch="$1" 17 | fi 18 | 19 | apt install -y $stuff || apt update && apt install -y $stuff || true 20 | 21 | mkdir -p $ipath 22 | 23 | function getGIT() { 24 | # getGIT $REPO $BRANCH $TARGET (directory) 25 | if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then echo "getGIT wrong usage, check your script or tell the author!" 1>&2; return 1; fi 26 | REPO="$1"; BRANCH="$2"; TARGET="$3"; pushd . 27 | if cd "$TARGET" &>/dev/null && git fetch --depth 1 origin "$BRANCH" && git reset --hard FETCH_HEAD; then popd; return 0; fi 28 | if ! cd /tmp || ! rm -rf "$TARGET"; then popd; return 1; fi 29 | if git clone --depth 1 --single-branch --branch "$2" "$1" "$3"; then popd; return 0; fi 30 | popd; return 1; 31 | } 32 | 33 | # get adsb-scripts repo 34 | getGIT "$repo" master "$ipath/git" 35 | 36 | bash "$ipath/git/libacars/install.sh" 37 | 38 | cd "$ipath/git/vdlm2dec" 39 | 40 | cp service /lib/systemd/system/vdlm2dec.service 41 | cp -n default /etc/default/vdlm2dec 42 | 43 | sed -i -e "s/XX-YYYYZ/$RANDOM-$RANDOM/" /etc/default/vdlm2dec 44 | 45 | # blacklist kernel driver as on ancient systems 46 | if grep -E 'wheezy|jessie' /etc/os-release -qs; then 47 | echo -e 'blacklist rtl2832\nblacklist dvb_usb_rtl28xxu\n' > /etc/modprobe.d/blacklist-rtl-sdr.conf 48 | rmmod rtl2832 &>/dev/null || true 49 | rmmod dvb_usb_rtl28xxu &>/dev/null || true 50 | fi 51 | 52 | adduser --system --home $ipath --no-create-home --quiet vdlm2dec 53 | adduser vdlm2dec plugdev 54 | 55 | GIT="$ipath/vdlm2dec-git" 56 | #getGIT https://github.com/TLeconte/vdlm2dec "$branch" "$GIT" 57 | getGIT https://github.com/wiedehopf/vdlm2dec "$branch" "$GIT" 58 | 59 | cd "$GIT" 60 | 61 | rm -rf build 62 | mkdir build 63 | cd build 64 | cmake .. -Drtl=ON 65 | make -j2 66 | 67 | BIN=/usr/local/bin/vdlm2dec 68 | rm -f $BIN 69 | cp -T vdlm2dec $BIN 70 | 71 | systemctl enable vdlm2dec 72 | systemctl restart vdlm2dec 73 | 74 | echo "-----------------------------------" 75 | echo "$SCRIPT_PATH completed successfully" 76 | echo "-----------------------------------" 77 | -------------------------------------------------------------------------------- /vdlm2dec/remove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | systemctl disable vdlm2dec 4 | systemctl stop vdlm2dec 5 | 6 | ipath=/usr/local/share/adsb-scripts 7 | rm "$ipath/vdlm2dec-git" -rf 8 | rm -v -f /lib/systemd/system/vdlm2dec.service /etc/default/vdlm2dec 9 | 10 | -------------------------------------------------------------------------------- /vdlm2dec/service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Wants=network.target 3 | After=network.target 4 | 5 | [Service] 6 | User=vdlm2dec 7 | EnvironmentFile=/etc/default/vdlm2dec 8 | SyslogIdentifier=vdlm2dec 9 | 10 | ExecStart=/usr/local/bin/vdlm2dec \ 11 | $OPTIONS0 \ 12 | $OPTIONS1 \ 13 | $OPTIONS2 \ 14 | $OPTIONS3 \ 15 | $OPTIONS4 \ 16 | $OPTIONS5 \ 17 | $OPTIONS6 \ 18 | $OPTIONS7 \ 19 | $OPTIONS8 \ 20 | $OPTIONS9 21 | 22 | Type=simple 23 | Restart=always 24 | RestartSec=30 25 | 26 | [Install] 27 | WantedBy=default.target 28 | -------------------------------------------------------------------------------- /zram-swap-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR 5 | 6 | ipath=/usr/local/share/adsb-scripts/zram-swap/ 7 | rm -rf $ipath 8 | mkdir -p $ipath 9 | cd $ipath 10 | 11 | wget -O $ipath/zram-swap.sh https://raw.githubusercontent.com/wiedehopf/adsb-scripts/master/zram-swap.sh 12 | wget -O /lib/systemd/system/zram-swap.service https://raw.githubusercontent.com/wiedehopf/adsb-scripts/master/zram-swap.service 13 | 14 | systemctl enable zram-swap 15 | systemctl start zram-swap 16 | 17 | echo "---------------------" 18 | echo "zram-swap installed." 19 | -------------------------------------------------------------------------------- /zram-swap.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=zram-swap - use zram as swap 3 | Documentation=https://github.com/wiedehopf/adsb-scripts/wiki/zram-swap 4 | 5 | [Service] 6 | ExecStart=/bin/bash /usr/local/share/adsb-scripts/zram-swap/zram-swap.sh 7 | Type=oneshot 8 | 9 | [Install] 10 | WantedBy=default.target 11 | -------------------------------------------------------------------------------- /zram-swap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR 5 | 6 | function vm_tweaks () { 7 | 8 | if grep /proc/sys/vm/swappiness 23 | 24 | # watermark_scale_factor 25 | # This factor controls the aggressiveness of kswapd. It defines the amount 26 | # of memory left in a node/system before kswapd is woken up and how much 27 | # memory needs to be free before kswapd goes back to sleep. 28 | # 80: 0.8 percent free memory (default 10 / 0.1%) 29 | echo 80 > /proc/sys/vm/watermark_scale_factor 30 | 31 | # watermark_boost_factor 32 | # this has to do with reclaiming on fragmentation, but with almost no memory available it can lead to kswapd thrashing 33 | # so it needs to be disabled 34 | echo 0 > /proc/sys/vm/watermark_boost_factor 35 | # some more explanation from this post: 36 | # https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1861359/comments/56 37 | # > What watermark boosting does is try to preemptively fire up kswapd to 38 | # > free memory when there hasn't been an allocation failure. It does this by 39 | # > increasing kswapd's high watermark goal and then firing up kswapd. The 40 | # > reason why this causes freezes is because, with the increased high 41 | # > watermark goal, kswapd will steal memory from processes that need it in 42 | # > order to make forward progress. These processes will, in turn, try to 43 | # > allocate memory again, which will cause kswapd to steal necessary pages 44 | # > from those processes again, in a positive feedback loop known as page 45 | # > thrashing. When page thrashing occurs, your system is essentially 46 | # > livelocked until the necessary forward progress can be made to stop 47 | # > processes from trying to continuously allocate memory and trigger kswapd 48 | # > to steal it back. 49 | 50 | # disable readahead for reading from swap (default is 3 which means 2^3 = 8 pages) 51 | echo 0 > /proc/sys/vm/page-cluster 52 | 53 | # raise vfs_cache_pressure a bit, default 100 54 | echo 150 > /proc/sys/vm/vfs_cache_pressure 55 | 56 | # write cache is less important with non-spinning disks 57 | # reduce the defaults to reduce write cache memory use just in case we're mem limited 58 | # ratio of available memory 59 | # dirty_background_ratio: start writing out data as soon as ratio pages are dirty (used for write cache) 60 | echo 2 > /proc/sys/vm/dirty_background_ratio 61 | # dirty_bytes_ratio: processes start writing out themselves (block) as soon as ratio pages are dirty 62 | echo 10 > /proc/sys/vm/dirty_ratio 63 | 64 | # raspbian sets min_free_kbytes at 16384 which wastes a lot of memory 65 | # the kernel default is a bit small though for weird networking quirks on the raspberry pi and possibly other SBCs 66 | # thus 8192 should be a good compromise for a stable system without wasting too much memory 67 | # only lower this setting if it's large and we have 1 GB or less memory 68 | # increase the setting if it's less than 8192 69 | min_free_kbytes=$(cat /proc/sys/vm/min_free_kbytes) 70 | total_mem_kbytes=$(grep -e MemTotal /proc/meminfo | tr -s ' ' | cut -d' ' -f2) 71 | if (( min_free_kbytes > 8192 )) && (( total_mem_kbytes < 2048 * 1024 )) || (( min_free_kbytes < 8192 )); then 72 | echo 8192 > /proc/sys/vm/min_free_kbytes 73 | fi 74 | 75 | # min_free_kbytes kernel defaults: 76 | # 512MB: 2896k 77 | # 1024MB: 4096k 78 | # 2048MB: 5792k 79 | # 4096MB: 8192k 80 | # 8192MB: 11584k 81 | # 16384MB: 16384k 82 | } 83 | 84 | NAME=zram0 85 | DEV=/dev/$NAME 86 | 87 | if { mount; cat /proc/swaps; } | grep -qs "$DEV"; then 88 | vm_tweaks 89 | echo "zram-swap.sh: $DEV is already mounted or used as swap, only applied virtual memory tweaks." 90 | exit 0 91 | fi 92 | 93 | echo "$(date -u +"%FT%T.%3NZ") zram-swap.sh setting up swap on zram" 94 | 95 | modprobe zram 96 | 97 | # reset the device to ensure we can set the parameters 98 | for i in {1..9}; do 99 | if echo 1 > "/sys/block/$NAME/reset"; then 100 | break 101 | fi 102 | sleep 1 103 | done 104 | 105 | # https://github.com/lz4/lz4?tab=readme-ov-file#benchmarks 106 | # Core i7-9700K single thread 107 | # Compressor Ratio Compression Decompression 108 | # LZ4 default (v1.9.0) 2.101 780 MB/s 4970 MB/s 109 | # Zstandard 1.4.0 -1 2.883 515 MB/s 1380 MB/s 110 | # 111 | # pi4b: 112 | # Testing using first 100MB of chrome binary: 113 | # 114 | # zstd zstd zstd zstd zstd zstd zstd zstd zstd zstd zstd zstd zstd zstd zstd zstd zstd zstd zstd zstd 115 | # from /run to zram: 104857600 bytes (105 MB, 100 MiB) copied, 2.78112 s, 37.7 MB/s 116 | # from zram to /run: 104857600 bytes (105 MB, 100 MiB) copied, 0.904138 s, 116 MB/s 117 | # uncompressed: 100.8M compressed: 49.5M 118 | # 119 | # lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 lz4 120 | # from /run to zram: 104857600 bytes (105 MB, 100 MiB) copied, 1.21295 s, 86.4 MB/s 121 | # from zram to /run: 104857600 bytes (105 MB, 100 MiB) copied, 0.436038 s, 240 MB/s 122 | # uncompressed: 100.8M compressed: 62.5M 123 | # 124 | echo lz4 > "/sys/block/$NAME/comp_algorithm" 125 | 126 | mem_kbytes="$(grep -e MemTotal /proc/meminfo | tr -s ' ' | cut -d' ' -f2)" 127 | 128 | # use 1/4 of memory 129 | use=$(( mem_kbytes / 4 )) 130 | 131 | # use at least 256M for systems with small memory 132 | min=$(( 256 * 1024 )) 133 | 134 | if (( use < min )); then 135 | size=$min 136 | else 137 | size=$use 138 | fi 139 | 140 | # zram maximum memory usage 141 | echo $(( size ))K > "/sys/block/$NAME/mem_limit" 142 | 143 | # disk size 144 | # let's make this 3x the memory limit in case we get good compression 145 | echo $(( 4 * size ))K > "/sys/block/$NAME/disksize" 146 | 147 | mkswap "$DEV" 148 | swapon -p 100 "$DEV" 149 | 150 | # turn off file based swap 151 | TURNOFF=$(grep /dev/null || true 15 | 16 | if ! [[ -e $DEV ]]; then 17 | cat /sys/class/zram-control/hot_add 18 | fi 19 | 20 | # reset the device to ensure we can set the parameters 21 | for i in {1..9}; do 22 | if echo 1 > "/sys/block/$NAME/reset"; then 23 | break 24 | fi 25 | sleep 1 26 | done 27 | 28 | # https://github.com/lz4/lz4?tab=readme-ov-file#benchmarks 29 | # Core i7-9700K single thread 30 | # Compressor Ratio Compression Decompression 31 | # LZ4 default (v1.9.0) 2.101 780 MB/s 4970 MB/s 32 | # Zstandard 1.4.0 -1 2.883 515 MB/s 1380 MB/s 33 | # 34 | # on a pi4, lz4 in compression has even higher relative speed over zstd 35 | # use zstd for now even though it's slower 36 | #echo lz4 > "/sys/block/$NAME/comp_algorithm" 37 | echo "$ALGO" > "/sys/block/$NAME/comp_algorithm" 38 | 39 | # use 1/4 of memory 40 | use=$(( $(grep -e MemTotal /proc/meminfo | tr -s ' ' | cut -d' ' -f2) / 4 )) 41 | 42 | # use at least 256M for systems with small memory 43 | min=$(( 256 * 1024 )) 44 | 45 | if (( use < min )); then 46 | size=$min 47 | else 48 | size=$use 49 | fi 50 | 51 | # zram maximum memory usage 52 | echo $(( size ))K > "/sys/block/$NAME/mem_limit" 53 | 54 | # disk size 55 | # let's make this 3x the memory limit in case we get good compression 56 | echo $(( 4 * size ))K > "/sys/block/$NAME/disksize" 57 | 58 | mkfs.ext2 "$DEV" &>/dev/null 59 | mkdir -p "$MOUNTPOINT" 60 | mount "$DEV" "$MOUNTPOINT" 61 | } 62 | 63 | function reset_cache() { 64 | sync 65 | #echo 3 > /proc/sys/vm/drop_caches 66 | } 67 | 68 | function test_zram_algo() { 69 | ALGO="$1" 70 | SIZE=100 71 | MP=/test_zram_algo 72 | ZRAM=zram1 73 | make_zram $ZRAM "$ALGO" $MP 74 | 75 | ZF=/$MP/testfile 76 | 77 | reset_cache 78 | 79 | echo 80 | echo "$ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO $ALGO" 81 | echo -n "from /run to zram: " 82 | dd if=$TF of=$ZF bs=1M oflag=dsync 2>&1 | grep -v records 83 | 84 | reset_cache 85 | echo 1 > /proc/sys/vm/drop_caches 86 | sleep 1 87 | 88 | echo -n "from zram to /run: " 89 | dd if=$ZF of=$TF bs=1M oflag=dsync 2>&1 | grep -v records 90 | 91 | reset_cache 92 | 93 | zramctl | grep $ZRAM | awk '{ print "uncompressed: ", $4, " compressed: ",$5 }' 94 | 95 | umount $MP || true 96 | echo 1 > "/sys/block/$ZRAM/reset" 97 | 98 | } 99 | 100 | function test_algos() { 101 | test_zram_algo zstd 102 | test_zram_algo lz4 103 | test_zram_algo lzo 104 | #test_zram_algo lzo-rle 105 | } 106 | 107 | DF=/tmp/zram_td_100.zst 108 | if ! [[ -f $DF ]]; then 109 | wget -O $DF https://github.com/wiedehopf/adsb-wiki/releases/download/compression_test/zram_td_100.zst 110 | fi 111 | 112 | TF=/run/zram_test_file 113 | 114 | echo 115 | echo "Testing using first 100MB of chrome binary:" 116 | 117 | zstd -f -d $DF -o $TF -q 118 | 119 | test_algos 120 | 121 | if [[ $1 == all ]]; then 122 | echo 123 | echo "Testing using 100MB random data" 124 | 125 | dd if=/dev/urandom of=$TF bs=1M count=100 status=none 126 | 127 | test_algos 128 | 129 | echo 130 | echo "Testing using 100MB zeroes" 131 | 132 | dd if=/dev/zero of=$TF bs=1M count=100 status=none 133 | 134 | test_algos 135 | fi 136 | 137 | rm -f "$TF" 138 | --------------------------------------------------------------------------------