2015-11-04 04:48:08 +00:00
#!/bin/bash
2024-07-22 04:43:50 +00:00
## PRE INSTALLATION OPERATIONS
2024-06-30 03:49:36 +00:00
source $RECEIVER_BASH_DIRECTORY /variables.sh
source $RECEIVER_BASH_DIRECTORY /functions.sh
2024-06-20 19:24:54 +00:00
clear
2024-07-23 21:39:20 +00:00
log_project_title
log_title_heading "Setting up the PlaneFinder client"
log_title_message "------------------------------------------------------------------------------"
2024-07-22 04:43:50 +00:00
if ! whiptail --backtitle " ${ RECEIVER_PROJECT_TITLE } " \
--title "PlaneFinder ADS-B Client Setup" \
--yesno "The PlaneFinder ADS-B Client is an easy and accurate way to share your ADS-B and MLAT data with Plane Finder. It comes with a beautiful user interface that helps you explore and interact with your data in realtime.\n\n https://planefinder.net/sharing/client\n\nContinue setup by installing PlaneFinder ADS-B Client?" \
13 78; then
2024-07-22 23:54:38 +00:00
echo ""
2024-07-23 21:39:20 +00:00
log_alert_heading "INSTALLATION HALTED"
log_alert_message "Setup has been halted at the request of the user"
2024-07-22 04:43:50 +00:00
echo ""
2024-07-23 21:39:20 +00:00
log_title_message "------------------------------------------------------------------------------"
log_title_heading "PlaneFinder client setup halted"
2024-07-22 04:43:50 +00:00
echo ""
2016-09-06 19:34:19 +00:00
exit 1
fi
2015-11-04 04:48:08 +00:00
2024-06-30 03:49:36 +00:00
## CHECK FOR PREREQUISITE PACKAGES
2017-10-02 19:36:29 +00:00
2024-07-23 21:39:20 +00:00
log_heading "Installing packages needed to fulfill PlaneFinder client dependencies"
2024-07-22 04:43:50 +00:00
2024-07-23 21:39:20 +00:00
check_package wget
2024-06-25 01:59:51 +00:00
2024-07-11 02:34:59 +00:00
case " ${ RECIEVER_CPU_ARCHITECTURE } " in
2024-06-25 01:59:51 +00:00
"aarch64" )
sudo dpkg --add-architecture armhf
2024-07-23 21:39:20 +00:00
check_package libc6:armhf
2024-06-25 01:59:51 +00:00
; ;
esac
2024-06-20 19:24:54 +00:00
2024-06-30 03:49:36 +00:00
2024-07-22 04:43:50 +00:00
## DOWNLOAD AND INSTALL THE PROPER PLANEFINDER CLIENT DEBIAN PACKAGE
2024-07-23 21:39:20 +00:00
log_heading "Begining the PlaneFinder client installation process"
2024-06-20 19:24:54 +00:00
2024-07-22 04:43:50 +00:00
2024-07-23 21:39:20 +00:00
log_message "Determining which Debian package to install"
2024-07-07 18:35:11 +00:00
case " ${ RECIEVER_CPU_ARCHITECTURE } " in
2024-07-24 00:38:11 +00:00
"armv7l" | "armv6l" | "aarch64" )
package_name = " pfclient_ ${ pfclient_current_version_armhf } _armhf.deb "
2024-06-20 19:24:54 +00:00
; ;
"x86_64" )
2024-07-24 00:38:11 +00:00
package_name = " pfclient_ ${ pfclient_current_version_amd64 } _amd64.deb "
2024-06-20 19:24:54 +00:00
; ;
"i386" )
2024-07-24 00:38:11 +00:00
package_name = " pfclient_ ${ pfclient_current_version_amd64 } _i386.deb "
2024-06-20 19:24:54 +00:00
; ;
*)
2024-07-22 04:43:50 +00:00
echo ""
2024-07-23 21:39:20 +00:00
log_alert_heading "INSTALLATION HALTED"
2024-07-22 04:43:50 +00:00
echo ""
2024-07-23 21:39:20 +00:00
log_alert_message "Unsupported CPU Archetecture"
log_alert_message " Archetecture Detected: ${ CPU_ARCHITECTURE } "
log_alert_message "Setup has been terminated"
2024-07-22 04:43:50 +00:00
echo ""
2024-07-23 21:39:20 +00:00
log_title_message "------------------------------------------------------------------------------"
log_title_heading "PlaneFinder client setup failed"
2024-07-22 04:43:50 +00:00
echo ""
read -p "Press enter to continue..." discard
2024-06-20 19:24:54 +00:00
exit 1
; ;
esac
2015-11-04 04:48:08 +00:00
2024-06-30 03:49:36 +00:00
if [ [ ! -d $RECEIVER_BUILD_DIRECTORY /planefinder ] ] ; then
2024-07-23 21:39:20 +00:00
log_message "Creating the PlaneFinder build directory"
2017-10-03 00:40:46 +00:00
echo ""
2024-06-30 03:49:36 +00:00
mkdir -vp $RECEIVER_BUILD_DIRECTORY /planefinder
2018-02-25 03:11:58 +00:00
echo ""
2016-09-06 19:34:19 +00:00
fi
2024-07-23 21:39:20 +00:00
log_message "Entering the PlaneFinder build directory"
2024-07-22 04:43:50 +00:00
cd $RECEIVER_BUILD_DIRECTORY /planefinder
2017-10-02 19:36:29 +00:00
2024-07-23 21:39:20 +00:00
log_message "Downloading the appropriate PlaneFinder client Debian package"
2024-06-20 19:24:54 +00:00
echo ""
2024-07-22 23:54:38 +00:00
wget -v -O $RECEIVER_BUILD_DIRECTORY /planefinder/$package_name http://client.planefinder.net/$package_name 2>& 1 | tee -a $RECEIVER_LOG_FILE
echo ""
2017-10-02 19:36:29 +00:00
2024-07-23 21:39:20 +00:00
log_message "Installing the PlaneFinder Client Debian package"
2024-06-20 19:24:54 +00:00
echo -e ""
2024-07-22 21:57:59 +00:00
sudo dpkg -i $RECEIVER_BUILD_DIRECTORY /planefinder/$package_name 2>& 1 | tee -a $RECEIVER_LOG_FILE
2024-06-20 19:24:54 +00:00
echo ""
2017-10-02 19:36:29 +00:00
2024-07-22 04:43:50 +00:00
if [ [ ! -d $RECEIVER_BUILD_DIRECTORY /package-archive ] ] ; then
2024-07-23 21:39:20 +00:00
log_message "Creating the package archive directory"
2024-07-22 04:43:50 +00:00
echo ""
2024-07-22 21:57:59 +00:00
mkdir -v $RECEIVER_BUILD_DIRECTORY /package-archive 2>& 1 | tee -a $RECEIVER_LOG_FILE
2024-07-22 04:43:50 +00:00
echo ""
2015-12-15 17:33:59 +00:00
fi
2024-07-23 21:39:20 +00:00
log_message "Copying the PlaneFinder client Debian package into the archive directory"
2024-07-22 04:43:50 +00:00
echo ""
2024-07-22 21:57:59 +00:00
cp -vf $RECEIVER_BUILD_DIRECTORY /planefinder/$package_name $RECEIVER_BUILD_DIRECTORY /package-archive/ 2>& 1 | tee -a $RECEIVER_LOG_FILE
2024-07-22 04:43:50 +00:00
echo ""
2015-12-15 17:33:59 +00:00
2024-07-22 04:43:50 +00:00
## POST INSTALLATION OPERATIONS
2024-06-30 03:49:36 +00:00
2024-07-23 21:39:20 +00:00
log_heading "Performing post installation operations"
2015-11-04 04:48:08 +00:00
2024-07-23 21:39:20 +00:00
log_message "Displaying the message informing the user on how to complete setup"
2017-10-03 00:40:46 +00:00
RECEIVER_IP_ADDRESS = ` ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/' `
2024-07-22 04:43:50 +00:00
whiptail --backtitle " ${ RECEIVER_PROJECT_TITLE } " \
--title "PlaneFinder ADS-B Client Setup Instructions" \
--msgbox " At this point the PlaneFinder ADS-B Client should be installed and running; however this script is only capable of installing the PlaneFinder ADS-B Client. There are still a few steps left which you must manually do through the PlaneFinder ADS-B Client at the following URL:\n\n http:// ${ RECEIVER_IP_ADDRESS } :30053\n\nThe follow the instructions supplied by the PlaneFinder ADS-B Client.\n\nUse the following settings when asked for them.\n\nData Format: Beast\nTcp Address: 127.0.0.1\nTcp Port: 30005 " \
20 78
2016-09-06 19:34:19 +00:00
2024-06-30 03:49:36 +00:00
## SETUP COMPLETE
2016-09-06 19:34:19 +00:00
2024-07-23 21:39:20 +00:00
log_message " Returning to ${ RECEIVER_PROJECT_TITLE } root directory "
2024-07-22 04:43:50 +00:00
cd $RECEIVER_ROOT_DIRECTORY
2016-09-06 19:34:19 +00:00
2024-07-22 04:43:50 +00:00
echo ""
2024-07-23 21:39:20 +00:00
log_title_message "------------------------------------------------------------------------------"
log_title_heading "PlaneFinder client setup is complete"
2024-07-22 04:43:50 +00:00
echo ""
2024-06-30 03:49:36 +00:00
read -p "Press enter to continue..." discard
2016-09-06 19:34:19 +00:00
exit 0