Added untested Nobel support and logging foundations.

pull/593/head
jprochazka 2024-07-19 15:58:45 -04:00
rodzic 7c91ec632b
commit 0bd32ef097
2 zmienionych plików z 166 dodań i 116 usunięć

Wyświetl plik

@ -1,38 +1,34 @@
#!/bin/bash #!/bin/bash
## INCLUDE EXTERNAL SCRIPTS # THE FLIGHTAWARE PIAWARE CLIENT SETUP SCRIPT
## PRE INSTALLATION OPERATIONS
source $RECEIVER_BASH_DIRECTORY/variables.sh source $RECEIVER_BASH_DIRECTORY/variables.sh
source $RECEIVER_BASH_DIRECTORY/functions.sh source $RECEIVER_BASH_DIRECTORY/functions.sh
## BEGIN SETUP
clear clear
echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}" LogProjectName ${RECEIVER_PROJECT_TITLE}
echo "" LogTitleHeading "Setting up the FlightAware PiAware Client"
echo -e "\e[92m Setting up FlightAware PiAware client..." LogTitleMessage "------------------------------------------------------------------------------"
echo ""
echo -e "\e[93m ------------------------------------------------------------------------------\e[96m"
echo "" echo ""
# Confirm component installation
if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "FlightAware PiAware client Setup" --yesno "The FlightAware PiAware client takes data from a local dump1090 instance and shares this with FlightAware using the piaware package, for more information please see their website:\n\n https://www.flightaware.com/adsb/piaware/\n\nContinue setup by installing the FlightAware PiAware client?" 13 78 3>&1 1>&2 2>&3; then if ! whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "FlightAware PiAware client Setup" --yesno "The FlightAware PiAware client takes data from a local dump1090 instance and shares this with FlightAware using the piaware package, for more information please see their website:\n\n https://www.flightaware.com/adsb/piaware/\n\nContinue setup by installing the FlightAware PiAware client?" 13 78 3>&1 1>&2 2>&3; then
echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" LogAlertHeading "INSTALLATION HALTED"
echo -e " Setup has been halted at the request of the user." LogAlertMessage "Setup has been halted at the request of the user"
echo "" echo ""
echo -e "\e[93m ------------------------------------------------------------------------------" LogTitleMessage "------------------------------------------------------------------------------"
echo -e "\e[92m FlightAware PiAware client setup halted.\e[39m" LogTitleHeading "ADS-B Receiver Portal setup halted"
echo "" echo ""
read -p "Press enter to continue..." discard
exit 1 exit 1
fi fi
## CHECK FOR PREREQUISITE PACKAGES ## CHECK FOR PREREQUISITE PACKAGES
echo -e "\e[95m Installing packages needed to fulfill dependencies for FlightAware PiAware client...\e[97m" LogHeading "Installing packages needed to fulfill dependencies for FlightAware PiAware client"
echo ""
CheckPackage build-essential CheckPackage build-essential
CheckPackage git CheckPackage git
CheckPackage devscripts CheckPackage devscripts
@ -60,96 +56,109 @@ CheckPackage libssl-dev
CheckPackage tcl-dev CheckPackage tcl-dev
CheckPackage chrpath CheckPackage chrpath
# Some older distros may need different packages than newer ones if "${RECEIVER_OS_CODE_NAME}" == "noble"
case ${RECEIVER_OS_CODE_NAME} in CheckPackage python3-pyasyncore
focal) fi
CheckPackage python3-dev
;;
*)
CheckPackage python3-build
;;
esac
echo "" if "${RECEIVER_OS_CODE_NAME}" == "focal"
CheckPackage python3-dev
## DOWNLOAD OR UPDATE THE TCLTLS REBUILD SOURCE
echo -e "\e[95m Preparing the tcltls rebuild Git repository...\e[97m"
echo ""
# Build the FlightAware version of tcl-tls to address network issues with the stock package
if [[ -d $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild && -d $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/.git ]]; then
# A directory with a git repository containing the source code already exists
echo -e "\e[94m Entering the tcltls-rebuild git repository directory...\e[97m"
cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild 2>&1
echo -e "\e[94m Updating the local tcltls-rebuild git repository...\e[97m"
echo ""
git pull 2>&1
else else
# A directory containing the source code does not exist in the build directory CheckPackage python3-build
echo -e "\e[94m Entering the ADS-B Receiver Project build directory...\e[97m" fi
cd $RECEIVER_BUILD_DIRECTORY 2>&1
echo -e "\e[94m Cloning the tcltls-rebuild git repository locally...\e[97m" echo ""
## CLONE OR PULL THE TCLTLS REBUILD GIT REPOSITORY
LogHeading "Preparing the FlightAware tcltls-rebuild Git repository"
if [[ -d $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild && -d $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/.git ]]; then
LogMessage "Entering the tcltls-rebuild git repository directory"
cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild
LogMessage "Updating the local tcltls-rebuild git repository"
echo "" echo ""
git clone https://github.com/flightaware/tcltls-rebuild 2>&1 git pull
else
LogMessage "Entering the ADS-B Receiver Project build directory"
cd $RECEIVER_BUILD_DIRECTORY
LogMessage "Cloning the tcltls-rebuild git repository locally"
echo ""
git clone https://github.com/flightaware/tcltls-rebuild
fi fi
echo "" echo ""
## BUILD AND INSTALL THE DUMP1090-FA PACKAGE ## BUILD AND INSTALL THE TCLTLS-REBUILD PACKAGE
echo -e "\e[95m Building and installing the tcltls rebuild package...\e[97m" LogHeading "Beginning the FlightAware tcltls-rebuild installation process"
echo -e ""
echo -e "\e[94m Entering the tcltls-rebuild source directory...\e[97m" LogMessage "Entering the tcltls-rebuild source directory"
cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/tcltls-1.7.22 2>&1 cd $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/tcltls-1.7.22
echo -e "\e[94m Building the tcltls-rebuild package...\e[97m" LogMessage "Building the tcltls-rebuild package"
echo "" echo ""
dpkg-buildpackage -b 2>&1 dpkg-buildpackage -b
echo "" echo ""
echo -e "\e[94m Installing the tcltls-rebuild package...\e[97m" LogMessage "Installing the tcltls-rebuild package"
echo "" echo ""
sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/tcl-tls_1.7.22-2+fa1_*.deb 2>&1 sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/tcl-tls_1.7.22-2+fa1_*.deb
echo ""
echo -e "\e[94m Moving the tcltls-rebuild binary package into the archive directory...\e[97m"
echo ""
cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1
echo "" echo ""
LogMessage "Checking that the FlightAware tcltls-rebuild package was installed properly"
if [[ $(dpkg-query -W -f='${STATUS}' tcltls 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then
echo ""
LogAlertHeading "INSTALLATION HALTED"
echo ""
LogAlertMessage "FlightAware tcltls-rebuild package installation failed"
LogAlertMessage "Setup has been terminated"
echo ""
LogTitleMessage "------------------------------------------------------------------------------"
LogTitleHeading "FlightAware PiAware client setup failed"
echo ""
read -p "Press enter to continue..." discard
exit 1
else
if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then
LogMessage "Creating the package archive directory"
echo ""
mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive
echo ""
fi
LogMessage "Copying the FlightAware tcltls-rebuild binary package into the archive directory"
echo ""
cp -vf $RECEIVER_BUILD_DIRECTORY/tcltls-rebuild/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/
echo ""
fi
## START INSTALLATION
echo -e "\e[95m Begining the FlightAware PiAware client installation process...\e[97m" ## CLONE OR PULL THE PIAWARE_BUILDER GIT REPOSITORY
echo ""
LogHeading "Preparing the FlightAware piaware_builder Git repository"
if [[ -d $RECEIVER_BUILD_DIRECTORY/piaware_builder && -d $RECEIVER_BUILD_DIRECTORY/piaware_builder/.git ]]; then if [[ -d $RECEIVER_BUILD_DIRECTORY/piaware_builder && -d $RECEIVER_BUILD_DIRECTORY/piaware_builder/.git ]]; then
# A directory with a git repository containing the source code already exists LogMessage "Entering the piaware_builder git repository directory"
echo -e "\e[94m Entering the piaware_builder git repository directory...\e[97m" cd $RECEIVER_BUILD_DIRECTORY/piaware_builder
cd $RECEIVER_BUILD_DIRECTORY/piaware_builder 2>&1 LogMessage "Updating the local piaware_builder git repository"
echo -e "\e[94m Updating the local piaware_builder git repository...\e[97m"
echo "" echo ""
git pull 2>&1 git pull
else else
# A directory containing the source code does not exist in the build directory LogMessage "Entering the ADS-B Receiver Project build directory"
echo -e "\e[94m Entering the ADS-B Receiver Project build directory...\e[97m" cd $RECEIVER_BUILD_DIRECTORY
cd $RECEIVER_BUILD_DIRECTORY 2>&1 LogMessage "Cloning the piaware_builder git repository locally"
echo -e "\e[94m Cloning the piaware_builder git repository locally...\e[97m"
echo "" echo ""
git clone https://github.com/flightaware/piaware_builder.git 2>&1 git clone https://github.com/flightaware/piaware_builder.git
fi fi
echo "" echo ""
## BUILD AND INSTALL THE COMPONENT PACKAGE ## BUILD AND INSTALL THE PIAWARE PACKAGE
echo -e "\e[95m Building and installing the FlightAware PiAware client package...\e[97m" LogHeading "Beginning the FlightAware PiAware installation process"
echo ""
# Change to the component build directory LogMessage "Entering the piaware_builder git repository directory"
echo -e "\e[94m Entering the piaware_builder git repository directory...\e[97m" cd $RECEIVER_BUILD_DIRECTORY/piaware_builder
cd $RECEIVER_BUILD_DIRECTORY/piaware_builder 2>&1
# Execute build script LogMessage "Determining which piaware_builder build strategy should be use"
distro="bookworm" distro="bookworm"
case $RECEIVER_OS_CODE_NAME in case $RECEIVER_OS_CODE_NAME in
buster | focal) buster | focal)
@ -158,80 +167,70 @@ case $RECEIVER_OS_CODE_NAME in
bullseye | jammy) bullseye | jammy)
distro="bullseye" distro="bullseye"
;; ;;
bookworm) bookworm | noble)
distro="bookworm" distro="bookworm"
;; ;;
esac esac
echo -e "\e[94m Executing the FlightAware PiAware client build script...\e[97m"
LogMessage "Executing the FlightAware PiAware client build script"
echo "" echo ""
./sensible-build.sh $distro ./sensible-build.sh $distro
echo "" echo ""
LogMessage "Entering the FlightAware PiAware client build directory"
# Change to build script directory cd $RECEIVER_BUILD_DIRECTORY/piaware_builder/package-${distro}
echo -e "\e[94m Entering the FlightAware PiAware client build directory...\e[97m" LogMessage "Building the FlightAware PiAware client package"
cd $RECEIVER_BUILD_DIRECTORY/piaware_builder/package-${distro} 2>&1
# Build binary package
echo -e "\e[94m Building the FlightAware PiAware client package...\e[97m"
echo "" echo ""
dpkg-buildpackage -b 2>&1 dpkg-buildpackage -b
echo "" echo ""
LogMessage "Installing the FlightAware PiAware client package"
# Install binary package
echo -e "\e[94m Installing the FlightAware PiAware client package...\e[97m"
echo "" echo ""
sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/piaware_builder/piaware_*.deb 2>&1 sudo dpkg -i $RECEIVER_BUILD_DIRECTORY/piaware_builder/piaware_*.deb 2>&1
echo "" echo ""
# Check that the component package was installed successfully. LogMessage "Checking that the FlightAware PiAware client package was installed properly"
echo -e "\e[94m Checking that the FlightAware PiAware client package was installed properly...\e[97m"
if [[ $(dpkg-query -W -f='${STATUS}' piaware 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then if [[ $(dpkg-query -W -f='${STATUS}' piaware 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then
echo "" echo ""
echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m" LogAlertHeading "INSTALLATION HALTED"
echo -e " UNABLE TO INSTALL A REQUIRED PACKAGE."
echo -e " SETUP HAS BEEN TERMINATED!"
echo "" echo ""
echo -e "\e[93mThe package \"piaware\" could not be installed.\e[39m" LogAlertMessage "FlightAware PiAware package installation failed"
LogAlertMessage "Setup has been terminated"
echo "" echo ""
echo -e "\e[93m ------------------------------------------------------------------------------" LogTitleMessage "------------------------------------------------------------------------------"
echo -e "\e[92m FlightAware PiAware client setup halted.\e[39m" LogTitleHeading "FlightAware PiAware client setup failed"
echo "" echo ""
read -p "Press enter to continue..." discard read -p "Press enter to continue..." discard
exit 1 exit 1
else else
# Create binary package archive directory.
if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then if [[ ! -d $RECEIVER_BUILD_DIRECTORY/package-archive ]]; then
echo -e "\e[94m Creating package archive directory...\e[97m" LogMessage "Creating the package archive directory"
echo "" echo ""
mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive 2>&1 mkdir -vp $RECEIVER_BUILD_DIRECTORY/package-archive
echo "" echo ""
fi fi
LogMessage "Copying the FlightAware PiAware client binary package into the archive directory"
# Archive binary package.
echo -e "\e[94m Moving the FlightAware PiAware client binary package into the archive directory...\e[97m"
echo "" echo ""
cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/ 2>&1 cp -vf $RECEIVER_BUILD_DIRECTORY/piaware_builder/*.deb $RECEIVER_BUILD_DIRECTORY/package-archive/
echo "" echo ""
fi fi
## COMPONENT POST INSTALL ACTIONS ## POST INSTALLATION OPERATIONS
# Instruct the user as to how they can claim their receiver online. LogHeading "Performing post installation operations"
LogMessage "Displaying the message informing the user on how to claim their device"
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Claiming Your PiAware Device" --msgbox "FlightAware requires you claim your feeder online using the following URL:\n\n http://flightaware.com/adsb/piaware/claim\n\nTo claim your device simply visit the address listed above." 12 78 whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Claiming Your PiAware Device" --msgbox "FlightAware requires you claim your feeder online using the following URL:\n\n http://flightaware.com/adsb/piaware/claim\n\nTo claim your device simply visit the address listed above." 12 78
## SETUP COMPLETE ## SETUP COMPLETE
# Return to the project root directory. LogMessage "Returning to ${RECEIVER_PROJECT_TITLE} root directory"
echo -e "\e[94m Returning to ${RECEIVER_PROJECT_TITLE} root directory...\e[97m" cd $RECEIVER_ROOT_DIRECTORY
cd $RECEIVER_ROOT_DIRECTORY 2>&1
echo "" echo ""
echo -e "\e[93m ------------------------------------------------------------------------------" LogTitleMessage "------------------------------------------------------------------------------"
echo -e "\e[92m FlightAware PiAware client setup is complete.\e[39m" LogTitleHeading "FlightAware PiAware client setup is complete"
echo "" echo ""
read -p "Press enter to continue..." discard read -p "Press enter to continue..." discard
exit 0 exit 0

Wyświetl plik

@ -98,3 +98,54 @@ function UncommentConfig {
sudo sed -i "/#${1}*/ s/#*//" $2 sudo sed -i "/#${1}*/ s/#*//" $2
fi fi
} }
## LOGGING
# Logs the "PROJECT NAME" to the console
function LogProjectName {
echo -e "${DISPLAY_PROJECT_NAME} ${1}${DISPLAY_DEFAULT}"
echo ""
}
# Logs a "HEADING" to the console
function LogHeading {
echo ""
echo -e "${DISPLAY_HEADING} ${1}${DISPLAY_DEFAULT}"
echo ""
}
# Logs a "MESSAGE" to the console
function LogMessage {
echo -e "${DISPLAY_MESSAGE} ${1}${DISPLAY_DEFAULT}"
}
# Logs an alert "HEADING" to the console
function LogAlertHeading {
echo -e "${DISPLAY_ALERT_HEADING} ${1}${DISPLAY_DEFAULT}"
}
# Logs an alert "MESSAGE" to the console
function LogAlertMessage {
echo -e "${DISPLAY_ALERT_MESSAGE} ${1}${DISPLAY_DEFAULT}"
}
# Logs an title "HEADING" to the console
function LogTitleHeading {
echo -e "${DISPLAY_TITLE_HEADING} ${1}${DISPLAY_DEFAULT}"
}
# Logs an title "MESSAGE" to the console
function LogTitleMessage {
echo -e "${DISPLAY_TITLE_MESSAGE} ${1}${DISPLAY_DEFAULT}"
}
# Logs a warning "HEADING" to the console
function LogWarningHeading {
echo -e "${DISPLAY_WARNING_HEADING} ${1}${DISPLAY_DEFAULT}"
}
# Logs a warning "MESSAGE" to the console
function LogWarningMessage {
echo -e "${DISPLAY_WARNING_MESSAGE} ${1}${DISPLAY_DEFAULT}"
}