adsb-receiver/bash/main.sh

489 wiersze
16 KiB
Bash
Czysty Zwykły widok Historia

#!/bin/bash
## INCLUDE EXTERNAL SCRIPTS
source ${RECEIVER_BASH_DIRECTORY}/variables.sh
source ${RECEIVER_BASH_DIRECTORY}/functions.sh
2024-07-23 18:45:59 +00:00
## 1090MHZ DECODERS
# FlightAware dump1090
install_1090mhz_decoder="false"
if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") == 1 ]] ; then
chosen_1090mhz_decoder="dump1090-fa"
2024-07-24 00:38:11 +00:00
if [[ $(sudo dpkg -s dump1090-fa 2>/dev/null | grep -c "Version: ${dump1090_fa_current_version}") == 0 ]] ; then
2024-07-23 18:45:59 +00:00
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "FlightAware Dump1090 Upgrade Available" \
--defaultno \
--yesno "An updated version of FlightAware dump1090 is available.\n\nWould you like to install the new version?" \
16 65
if [[ $? == 0 ]]; then
install_1090mhz_decoder="true"
fi
fi
2024-07-23 18:45:59 +00:00
else
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "FlightAware dump978" \
--defaultno \
--yesno "FlightAware dump1090 is capable of demodulating ADS-B, Mode S, Mode 3A/3C signals received by an SDR device.\n\nGitHub Repository: https://github.com/flightaware/dump1090\n\nWould you like to install FlightAware dump1090?" \
10 65
if [[ $? == 0 ]]; then
install_978mhz_decoder="true"
fi
2024-07-23 18:45:59 +00:00
fi
2024-07-23 18:45:59 +00:00
function install_dump1090-fa() {
${RECEIVER_BASH_DIRECTORY}/decoders/dump1090-fa.sh
if [[ $? != 0 ]] ; then
exit 1
fi
}
2024-07-13 19:32:48 +00:00
2024-07-23 18:45:59 +00:00
## 978MHZ DECODERS
# Flightaware dump978
install_978mhz_decoder="false"
if [[ $(dpkg-query -W -f='${STATUS}' dump978-fa 2>/dev/null | grep -c "ok installed") == 1 ]]; then
chosen_978mhz_decoder="dump978-fa"
2024-07-24 00:38:11 +00:00
if [[ $(sudo dpkg -s dump978-fa 2>/dev/null | grep -c "Version: ${dump978_fa_current_version}") == 0 ]]; then
2024-07-23 18:45:59 +00:00
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "FlightAware dump978 Upgrade Available" \
--defaultno --yesno "An updated version of FlightAware dump978 is available.\n\nWould you like to install the new version?" \
16 65
if [[ $? == 0 ]]; then
install_978mhz_decoder="true"
fi
fi
2024-07-23 18:45:59 +00:00
else
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "FlightAware dump978" \
--defaultno \
--yesno "FlightAware dump978 is capable of demodulating UAT received by an SDR device.\n\nGitHub Repository: https://github.com/flightaware/dump978\n\nWould you like to install FlightAware dump978?" \
10 65
if [[ $? == 0 ]]; then
install_978mhz_decoder="true"
fi
2024-07-23 18:45:59 +00:00
fi
2024-07-23 18:45:59 +00:00
function install_dump978-fa() {
${RECEIVER_BASH_DIRECTORY}/decoders/dump978-fa.sh
if [[ $? != 0 ]] ; then
2018-06-26 13:06:46 +00:00
exit 1
fi
}
2024-07-24 00:38:11 +00:00
2024-07-23 18:45:59 +00:00
## AGGREGATE SITE CLIENTS
2024-07-23 18:45:59 +00:00
declare array feeder_list
touch ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES
# ADS-B Exchange
if [[ -f /lib/systemd/system/adsbexchange-mlat.service && -f /lib/systemd/system/adsbexchange-feed.service ]]; then
echo "ADS-B Exchange Feed Client (reinstall)" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES
2024-07-24 00:38:11 +00:00
feeder_list=("${feeder_list[@]}" 'ADS-B Exchange Feed Client (reinstall/update)' '' OFF)
2024-07-23 18:45:59 +00:00
else
echo "ADS-B Exchange Feed Client" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES
feeder_list=("${feeder_list[@]}" 'ADS-B Exchange Feed Client' '' OFF)
fi
function install_adsbexchange_client() {
${RECEIVER_BASH_DIRECTORY}/feeders/adsbexchange.sh
if [[ $? != 0 ]] ; then
exit 1
fi
}
2024-07-23 18:45:59 +00:00
# Airplanes.live
if [[ -f /lib/systemd/system/airplanes-feed.service && -f /lib/systemd/system/airplanes-mlat.service ]]; then
echo "Airplanes.live Feeder (reinstall)" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES
feeder_list=("${feeder_list[@]}" 'Airplanes.live Feeder (reinstall)' '' OFF)
else
echo "Airplanes.live Feeder" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES
feeder_list=("${feeder_list[@]}" 'Airplanes.live Feeder' '' OFF)
fi
2024-07-23 18:45:59 +00:00
function install_airplaneslive_client() {
${RECEIVER_BASH_DIRECTORY}/feeders/airplaneslive.sh
if [[ $? != 0 ]] ; then
exit 1
fi
}
2024-07-23 18:45:59 +00:00
# FlightAware PiAware
if [[ $(dpkg-query -W -f='${STATUS}' piaware 2>/dev/null | grep -c "ok installed") == 0 ]]; then
feeder_list=("${feeder_list[@]}" 'FlightAware PiAware' '' OFF)
else
if [[ $(sudo dpkg -s piaware 2>/dev/null | grep -c "Version: ${piaware_current_version}") == 0 ]]; then
feeder_list=("${feeder_list[@]}" 'FlightAware PiAware (upgrade)' '' OFF)
else
feeder_list=("${feeder_list[@]}" 'FlightAware PiAware (reinstall)' '' OFF)
fi
2024-07-23 18:45:59 +00:00
fi
2024-07-23 18:45:59 +00:00
function install_flightaware_client() {
${RECEIVER_BASH_DIRECTORY}/feeders/piaware.sh
if [[ $? != 0 ]] ; then
exit 1
fi
}
2024-07-23 18:45:59 +00:00
# Flightradar24
if [[ $(dpkg-query -W -f='${STATUS}' fr24feed 2>/dev/null | grep -c "ok installed") == 0 ]]; then
feeder_list=("${feeder_list[@]}" 'Flightradar24 Client' '' OFF)
else
if [[ $(sudo dpkg -s fr24feed 2>/dev/null | grep -c "Version: ${fr24feed_current_version}") == 0 ]]; then
feeder_list=("${feeder_list[@]}" 'Flightradar24 Client (upgrade)' '' OFF)
else
feeder_list=("${feeder_list[@]}" 'Flightradar24 Client (reinstall)' '' OFF)
fi
fi
2024-07-23 18:45:59 +00:00
function install_flightradar24_client() {
${RECEIVER_BASH_DIRECTORY}/feeders/flightradar24.sh
if [[ $? != 0 ]] ; then
exit 1
fi
2024-07-23 18:45:59 +00:00
}
2024-07-13 19:32:48 +00:00
2024-07-23 18:45:59 +00:00
# Fly Italy ADS-B
if [[ -f /lib/systemd/system/flyitalyadsb-mlat.service && -f /lib/systemd/system/flyitalyadsb-feed.service ]]; then
echo "Fly Italy ADS-B Feeder (upgrade)" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES
2024-07-24 00:38:11 +00:00
feeder_list=("${feeder_list[@]}" 'Fly Italy ADS-B Feeder (reinstall)' '' OFF)
else
echo "Fly Italy ADS-B Feeder" >> ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES
2024-07-23 18:45:59 +00:00
feeder_list=("${feeder_list[@]}" 'Fly Italy ADS-B Feeder' '' OFF)
fi
2024-07-23 18:45:59 +00:00
function install_flyitalyadsb_client() {
${RECEIVER_BASH_DIRECTORY}/feeders/flyitalyadsb.sh
if [[ $? != 0 ]] ; then
exit 1
fi
2024-07-23 18:45:59 +00:00
}
2018-06-26 13:06:46 +00:00
2024-07-23 18:45:59 +00:00
# OpenSky Network
if [[ $(dpkg-query -W -f='${STATUS}' opensky-feeder 2>/dev/null | grep -c "ok installed") == 0 ]]; then
feeder_list=("${feeder_list[@]}" 'OpenSky Network Feeder' '' OFF)
else
2024-07-24 00:38:11 +00:00
if [[ $(sudo dpkg -s opensky-feeder 2>/dev/null | grep -c "Version: ${opensky_feeder_current_version}") == 0 ]]; then
2024-07-23 18:45:59 +00:00
feeder_list=("${feeder_list[@]}" 'OpenSky Network Feeder (reinstall)' '' OFF)
fi
fi
2024-07-23 18:45:59 +00:00
function install_openskynetwork_client() {
${RECEIVER_BASH_DIRECTORY}/feeders/openskynetwork.sh
if [[ $? != 0 ]] ; then
exit 1
fi
2024-07-23 18:45:59 +00:00
}
2024-07-23 18:45:59 +00:00
# Planefinder
if [[ $(dpkg-query -W -f='${STATUS}' pfclient 2>/dev/null | grep -c "ok installed") == 0 ]]; then
feeder_list=("${feeder_list[@]}" 'Plane Finder Client' '' OFF)
else
2024-07-23 18:45:59 +00:00
pfclient_installed_version=$(sudo dpkg -s pfclient | grep Version | awk '{print $2}')
2024-06-20 19:24:54 +00:00
case "${CPU_ARCHITECTURE}" in
"armv7l"|"armv6l")
2024-07-23 18:45:59 +00:00
if [[ "$pfclient_installed_version" != "${pfclient_current_version_armhf}" ]]; then
feeder_list=("${feeder_list[@]}" 'Plane Finder Client (upgrade)' '' OFF)
2024-06-20 19:24:54 +00:00
else
2024-07-23 18:45:59 +00:00
feeder_list=("${feeder_list[@]}" 'Plane Finder Client (reinstall)' '' OFF)
2024-06-20 19:24:54 +00:00
fi
;;
"aarch64")
2024-07-23 18:45:59 +00:00
if [[ "$pfclient_installed_version" != "${pfclient_current_version_arm64}" ]]; then
feeder_list=("${feeder_list[@]}" 'Plane Finder Client (upgrade)' '' OFF)
2024-06-20 19:24:54 +00:00
else
2024-07-23 18:45:59 +00:00
feeder_list=("${feeder_list[@]}" 'Plane Finder Client (reinstall)' '' OFF)
2024-06-20 19:24:54 +00:00
fi
;;
"x86_64")
2024-07-23 18:45:59 +00:00
if [[ "$pfclient_installed_version" != "${pfclient_current_version_amd64}" ]]; then
feeder_list=("${feeder_list[@]}" 'Plane Finder Client (upgrade)' '' OFF)
2024-06-20 19:24:54 +00:00
else
2024-07-23 18:45:59 +00:00
feeder_list=("${feeder_list[@]}" 'Plane Finder Client (reinstall)' '' OFF)
2024-06-20 19:24:54 +00:00
fi
;;
"i386")
2024-07-23 18:45:59 +00:00
if [[ "$pfclient_installed_version" != "${pfclient_current_version_i386}" ]]; then
feeder_list=("${feeder_list[@]}" 'Plane Finder Client (upgrade)' '' OFF)
2024-06-20 19:24:54 +00:00
else
2024-07-23 18:45:59 +00:00
feeder_list=("${feeder_list[@]}" 'Plane Finder Client (reinstall)' '' OFF)
2024-06-20 19:24:54 +00:00
fi
;;
*)
2024-07-23 18:45:59 +00:00
feeder_list=("${feeder_list[@]}" 'Plane Finder Client (reinstall)' '' OFF)
2024-06-20 19:24:54 +00:00
esac
fi
2024-07-23 18:45:59 +00:00
function install_planefinder_client() {
${RECEIVER_BASH_DIRECTORY}/feeders/planefinder.sh
if [[ $? != 0 ]] ; then
exit 1
fi
}
2024-07-23 18:45:59 +00:00
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "Client Installation Options" \
--checklist \
--nocancel \
--separate-output "The following clients are available for installation.\nChoose the clients you wish to install." \
15 65 7 "${feeder_list[@]}" 2>${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES
## PORTALS
# ADS-B Portal
install_portal="false"
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "Install The ADS-B Portal" \
--defaultno \
--yesno "The ADS-B Portal is a web interface for your receiver. More information can be found in the ADS-B Receiver Project GitHub repository.\n\nhttps://github.com/jprochazka/adsb-receiver\n\nWould you like to install the ADS-B Portal?" \
14 78
if [[ $? == 0 ]]; then
install_portal="true"
2024-07-24 00:38:11 +00:00
fi
2024-07-23 18:45:59 +00:00
function install_adsb-portal() {
${RECEIVER_BASH_DIRECTORY}/portal/install.sh
if [[ $? != 0 ]] ; then
exit 1
fi
}
## Extras
2024-07-23 18:45:59 +00:00
declare array extras_list
touch ${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES
2024-07-23 18:45:59 +00:00
# Beast-splitter
if [[ $(dpkg-query -W -f='${STATUS}' beast-splitter 2>/dev/null | grep -c "ok installed") == 0 ]]; then
extras_list=("${extras_list[@]}" 'beast-splitter' '' OFF)
else
2024-07-23 18:45:59 +00:00
extras_list=("${extras_list[@]}" 'beast-splitter (reinstall)' '' OFF)
fi
2024-07-24 00:38:11 +00:00
function install_beastsplitter() {
2024-07-23 18:45:59 +00:00
chmod +x ${RECEIVER_BASH_DIRECTORY}/extras/beeastsplitter.sh
${RECEIVER_BASH_DIRECTORY}/extras/beastsplitter.sh
if [[ $? != 0 ]] ; then
exit 1
fi
}
# Duck DNS
if [[ ! -f "${RECEIVER_BUILD_DIRECTORY}/duckdns/duck.sh" ]]; then
# Duck DNS does not appear to be set up on this device.
2024-07-23 18:45:59 +00:00
extras_list=("${extras_list[@]}" 'Duck DNS Free Dynamic DNS Hosting' '' OFF)
else
# Offer the option to install/setup Duck DNS once more.
2024-07-23 18:45:59 +00:00
extras_list=("${extras_list[@]}" 'Duck DNS Free Dynamic DNS Hosting (reinstall)' '' OFF)
fi
2024-07-24 00:38:11 +00:00
function install_duckdns() {
2024-07-23 18:45:59 +00:00
chmod +x ${RECEIVER_BASH_DIRECTORY}/extras/duckdns.sh
${RECEIVER_BASH_DIRECTORY}/extras/duckdns.sh
if [[ $? -ne 0 ]] ; then
exit 1
fi
}
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "Extras Installation Options" \
--checklist \
--nocancel \
--separate-output "The following extras are available for installation, please select any which you wish to install." \
13 65 4 "${extras_list[@]}" 2>${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES
## Setup Confirmation
2024-07-23 18:45:59 +00:00
declare confirmation_message
2024-07-23 18:45:59 +00:00
if [[ "${install_1090mhz_decoder}" == "false" && "${install_1090mhz_decoder}" == "false" && "${install_portal}" == "false" && ! -s "${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES" && ! -s "${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES" ]]; then
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "Nothing to be done" \
--msgbox "Nothing has been selected to be installed so the script will exit now." \
10 65
echo ""
2024-07-23 21:39:20 +00:00
log_alert_heading "Nothing was selected to do or be installed"
2024-07-23 18:45:59 +00:00
echo ""
exit 1
else
2024-07-23 18:45:59 +00:00
confirmation_message="The following software will be installed:\n"
# 1090MHz decoders
if [[ "${install_1090mhz_decoder}" == "true" ]]; then
case ${chosen_1090mhz_decoder} in
"dump1090-fa")
confirmation_message="${confirmation_message}\n * FlightAware dump1090"
;;
esac
fi
2024-07-23 18:45:59 +00:00
# 978MHz decoders
if [[ "${install_978mhz_decoder}" = "true" ]]; then
case ${chosen_978mhz_decoder} in
"dump978-fa")
confirmation_message="${confirmation_message}\n * FlightAware dump978"
;;
esac
fi
2024-07-23 18:45:59 +00:00
# Aggragate site clients
if [[ -s "${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES" ]]; then
2024-07-23 18:45:59 +00:00
while read feeder_choice
do
2024-07-23 18:45:59 +00:00
confirmation_message="${confirmation_message}\n * ${feeder_choice}"
done < ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES
fi
2024-07-23 18:45:59 +00:00
# Portals
if [[ "${WEBPORTAL_DO_INSTALL}" == "true" ]]; then
confirmation_message="${confirmation_message}\n * ADS-B Receiver Project Web Portal"
fi
2024-07-23 18:45:59 +00:00
# Extras
if [[ -s "${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES" ]]; then
2024-07-23 18:45:59 +00:00
while read extra_choice
do
2024-07-23 18:45:59 +00:00
confirmation_message="${confirmation_message}\n * ${extra_choice}"
done < ${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES
fi
2024-07-23 18:45:59 +00:00
confirmation_message="${confirmation_message}\n\n"
fi
2024-07-23 18:45:59 +00:00
confirmation_message="${confirmation_message}Do you wish to continue setup?"
if ! (whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Confirm You Wish To Continue" --yesno "${confirmation_message}" 21 78); then
echo ""
2024-07-23 21:39:20 +00:00
log_alert_heading "Installation cancelled by user"
2024-07-23 18:45:59 +00:00
echo ""
exit 1
fi
2024-07-23 18:45:59 +00:00
## BEGIN SETUP
2024-07-23 18:45:59 +00:00
# 1090MHz Decoders
if [[ "${install_1090mhz_decoder}" == "true" ]]; then
case ${chosen_1090mhz_decoder} in
"dump1090-fa")
install_dump1090-fa
;;
esac
fi
2024-07-23 18:45:59 +00:00
# 978MHz Decoders
if [[ "${install_978mhz_decoder}" == "true" ]]; then
case ${chosen_978mhz_decoder} in
"dump978-fa")
install_dump978-fa
;;
esac
fi
2024-07-24 00:38:11 +00:00
run_adsbexchange_script="false"
run_airplaneslive_script="false"
run_flightaware_script="false"
run_flightradar24_script="false"
run_flyitalyadsb_script="false"
run_openskynetwork_script="false"
run_planefinder_script="false"
2024-07-23 18:45:59 +00:00
# Aggragate site clients
if [[ -s "${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES" ]]; then
2024-07-23 18:45:59 +00:00
while read feeder_choice
do
2024-07-23 18:45:59 +00:00
case ${feeder_choice} in
2024-07-24 00:38:11 +00:00
"ADS-B Exchange Feed Client"|"ADS-B Exchange Feed Client (reinstall/update)")
run_adsbexchange_script="true"
2018-06-26 13:06:46 +00:00
;;
2024-07-13 19:32:48 +00:00
"Airplanes.live Feeder"|"Airplanes.live Feeder (reinstall)")
2024-07-24 00:38:11 +00:00
run_airplaneslive_script="true"
2024-07-13 19:32:48 +00:00
;;
"FlightAware PiAware"|"FlightAware PiAware (upgrade)"|"FlightAware PiAware (reinstall)")
2024-07-24 00:38:11 +00:00
run_flightaware_script="true"
;;
"Flightradar24 Client"|"Flightradar24 Client (upgrade)"|"Flightradar24 Client (reinstall)")
2024-07-24 00:38:11 +00:00
run_flightradar24_script="true"
;;
2024-07-24 00:38:11 +00:00
"Fly Italy ADS-B Feeder"|"Fly Italy ADS-B Feeder (reinstall)")
run_flyitalyadsb_script="true"
;;
2024-07-24 00:38:11 +00:00
"OpenSky Network Feeder"|"OpenSky Network Feeder (reinstall)")
run_openskynetwork_script="true"
2018-06-26 13:06:46 +00:00
;;
2024-06-20 19:24:54 +00:00
"Plane Finder Client"|"Plane Finder Client (upgrade)"|"Plane Finder Client (reinstall)")
2024-07-24 00:38:11 +00:00
run_planefinder_script="true"
;;
esac
done < ${RECEIVER_ROOT_DIRECTORY}/FEEDER_CHOICES
fi
2024-07-24 00:38:11 +00:00
if [[ "${run_adsbexchange_script}" == "true" ]]; then
install_adsbexchange_client
fi
if [[ "${run_airplaneslive_script}" == "true" ]]; then
install_airplaneslive_client
fi
if [[ "${run_flightaware_script}" == "true" ]]; then
install_flightaware_client
fi
if [[ "${run_flightradar24_script}" == "true" ]]; then
install_flightradar24_client
fi
if [[ "${run_flyitalyadsb_script}" == "true" ]]; then
install_flyitalyadsb_client
fi
if [[ "${run_openskynetwork_script}" == "true" ]]; then
install_openskynetwork_client
fi
if [[ "${run_planefinder_script}" == "true" ]]; then
install_planefinder_client
fi
2024-07-23 18:45:59 +00:00
# Portals
if [[ "${install_portal}" == "true" ]]; then
install_adsb-portal
2018-06-26 13:06:46 +00:00
fi
2024-07-23 18:45:59 +00:00
# Extras
2024-07-24 00:38:11 +00:00
run_beastsplitter_script="false"
run_duckdns_script="false"
if [[ -s "${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES" ]]; then
2024-07-23 18:45:59 +00:00
while read extras_choice
do
2024-07-23 18:45:59 +00:00
case ${extras_choice} in
"beast-splitter"|"beast-splitter (reinstall)")
2024-07-24 00:38:11 +00:00
run_beastsplitter_script="true"
;;
"Duck DNS Free Dynamic DNS Hosting"|"Duck DNS Free Dynamic DNS Hosting (reinstall)")
2024-07-24 00:38:11 +00:00
run_duckdns_script="true"
;;
esac
done < ${RECEIVER_ROOT_DIRECTORY}/EXTRAS_CHOICES
fi
2024-07-24 00:38:11 +00:00
if [[ "${run_adsbexchange_script}" == "true" ]]; then
install_beastsplitter
fi
if [[ "${run_duckdns_script}" == "true" ]]; then
install_duckdns
fi
exit 0