Merge pull request #55 from jprochazka/cleanup

Script cleanup.
pull/58/head
Joe Prochazka 2016-01-08 12:50:46 -05:00
commit 64389f7d78
12 zmienionych plików z 205 dodań i 302 usunięć

Wyświetl plik

@ -31,38 +31,10 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
BUILDDIR=${PWD}
BUILDDIR=$PWD
DUMP1090DIR="$BUILDDIR/dump1090"
## FUNCTIONS
# Function used to check if a package is install and if not install it.
ATTEMPT=1
function CheckPackage(){
if (( $ATTEMPT > 5 )); then
echo -e "\033[33mSCRIPT HALETED! \033[31m[FAILED TO INSTALL PREREQUISITE PACKAGE]\033[37m"
echo ""
exit 1
fi
printf "\e[33mChecking if the package $1 is installed..."
if [ $(dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
if (( $ATTEMPT > 1 )); then
echo -e "\033[31m [PREVIOUS INSTALLATION FAILED]\033[37m"
echo -e "\033[33mAttempting to Install the package $1 again in 5 seconds (ATTEMPT $ATTEMPT OF 5)..."
sleep 5
else
echo -e "\033[31m [NOT INSTALLED]\033[37m"
echo -e "\033[33mInstalling the package $1..."
fi
echo -e "\033[37m"
ATTEMPT=$((ATTEMPT+1))
sudo apt-get install -y $1;
echo ""
CheckPackage $1
else
echo -e "\033[32m [OK]\033[37m"
ATTEMPT=0
fi
}
source ../bash/functions.sh
clear
@ -97,12 +69,12 @@ CheckPackage lighttpd
## DOWNLOAD OR UPDATE THE DUMP1090-MUTABILITY SOURCE
# Check if the git repository already exists locally.
if [ -d "$BUILDDIR/dump1090" ] && [ -d $BUILDDIR/dump1090/.git ]; then
if [ -d $DUMP1090DIR ] && [ -d $DUMP1090DIR/.git ]; then
# A directory with a git repository containing the source code exists.
echo -e "\033[33m"
echo "Updating the local dump1090-mutability git repository..."
echo -e "\033[37m"
cd $BUILDDIR/dump1090
cd $DUMP1090DIR
git pull origin master
else
# A directory containing the source code does not exist in the build directory.
@ -117,7 +89,7 @@ fi
echo -e "\033[33m"
echo "Building the dump1090-mutability package..."
echo -e "\033[37m"
cd $BUILDDIR/dump1090
cd $DUMP1090DIR
dpkg-buildpackage -b
## INSTALL THE DUMP1090-MUTABILITY PACKAGE
@ -130,7 +102,7 @@ sudo dpkg -i dump1090-mutability_1.15~dev_*.deb
## CHECK THAT THE PACKAGE INSTALLED
if [ $(dpkg-query -W -f='${Status}' dump1090-mutability 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
if [ $(dpkg-query -W -f='${STATUS}' dump1090-mutability 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo "\033[31m"
echo "The dump1090-mutability package did not install properly!"
echo -e "\033[33m"
@ -167,7 +139,7 @@ sudo /etc/init.d/dump1090-mutability start
# Check if the heywhatsthis.com range position file has already been downloaded.
if [ ! -f /usr/share/dump1090-mutability/html/upintheair.json ]; then
echo -e "\033[33m"
echo "Dump1090-mutability is able to display terrain limit rings using data obtained."
echo "Dump1090-mutability is able to display terrain limit rings using data obtained"
echo "from the website http://www.heywhatsthat.com. Some work will be required on your"
echo "part including visiting http://www.heywhatsthat.com and generating a new"
echo "panorama set to your location."
@ -177,7 +149,6 @@ if [ ! -f /usr/share/dump1090-mutability/html/upintheair.json ]; then
if [[ ! $ADDTERRAINRINGS =~ ^[Nn]$ ]]; then
echo -e "\033[31m"
echo "READ THE FOLLOWING INSTRUCTION CAREFULLY!"
echo ""
echo -e "\033[33m"
echo "To set up terrain limit rings you will need to first generate a panorama on the website"
echo "heywhatsthat.com. To do so visit the following URL:"

Wyświetl plik

@ -31,38 +31,14 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
BUILDDIR=${PWD}
## VARIABLES
## FUNCTIONS
BUILDDIR=$PWD
ADSBEXCHANGEDIR="$BUILDDIR/adsbexchange"
# Function used to check if a package is install and if not install it.
ATTEMPT=1
function CheckPackage(){
if (( $ATTEMPT > 5 )); then
echo -e "\033[33mSCRIPT HALETED! \033[31m[FAILED TO INSTALL PREREQUISITE PACKAGE]\033[37m"
echo ""
exit 1
fi
printf "\e[33mChecking if the package $1 is installed..."
if [ $(dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
if (( $ATTEMPT > 1 )); then
echo -e "\033[31m [PREVIOUS INSTALLATION FAILED]\033[37m"
echo -e "\033[33mAttempting to Install the package $1 again in 5 seconds (ATTEMPT $ATTEMPT OF 5)..."
sleep 5
else
echo -e "\033[31m [NOT INSTALLED]\033[37m"
echo -e "\033[33mInstalling the package $1..."
fi
echo -e "\033[37m"
ATTEMPT=$((ATTEMPT+1))
sudo apt-get install -y $1;
echo ""
CheckPackage $1
else
echo -e "\033[32m [OK]\033[37m"
ATTEMPT=0
fi
}
source ../bash/functions.sh
## INFORMATIVE MESSAAGE ABOUT THIS SOFTWARE
clear
@ -108,7 +84,7 @@ fi
echo -e "\033[33mSetting permissions on adsbexchange-maint.sh..."
echo -e "\033[37m"
sudo chmod +x $BUILDDIR/adsbexchange/adsbexchange-maint.sh
sudo chmod +x $ADSBEXCHANGEDIR/adsbexchange-maint.sh
echo -e "\033[33mAdding startup line to rc.local..."
echo -e "\033[37m"
@ -119,7 +95,7 @@ lnum=($(sed -n '/exit 0/=' /etc/rc.local))
echo -e "\033[33mExecuting adsbexchange-maint.sh..."
echo -e "\033[37m"
sudo $BUILDDIR/adsbexchange/adsbexchange-maint.sh &
sudo $ADSBEXCHANGEDIR/adsbexchange-maint.sh &
echo -e "\033[33mConfiguration of the ADS-B Exchange feed is now complete."
echo "Please look over the output generated to be sure no errors were encountered."

Wyświetl plik

@ -31,46 +31,15 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Set to the most current stable version of PiAware available.
CURRENTVERSION="2.1-5-jessie"
## VAARIABLES
# This next line was added temporarily due to the fact the version of PiAware containing a certificate
# error fix is still pacakaged with the version number 2.1-5. This should be able to be removed once
# PiAware's versioning matches back up with that of the tag being used to build the packages.
CURRENTVERSIONNAME="2.1-5"
BUILDDIR=$PWD
PIAWAREDIR="$PWD/piaware_builder"
BUILDDIR=${PWD}
source ../bash/variables.sh
source ../bash/functions.sh
## FUNCTIONS
# Function used to check if a package is install and if not install it.
ATTEMPT=1
function CheckPackage(){
if (( $ATTEMPT > 5 )); then
echo -e "\033[33mSCRIPT HALETED! \033[31m[FAILED TO INSTALL PREREQUISITE PACKAGE]\033[37m"
echo ""
exit 1
fi
printf "\e[33mChecking if the package $1 is installed..."
if [ $(dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
if (( $ATTEMPT > 1 )); then
echo -e "\033[31m [PREVIOUS INSTALLATION FAILED]\033[37m"
echo -e "\033[33mAttempting to Install the package $1 again in 5 seconds (ATTEMPT $ATTEMPT OF 5)..."
sleep 5
else
echo -e "\033[31m [NOT INSTALLED]\033[37m"
echo -e "\033[33mInstalling the package $1..."
fi
echo -e "\033[37m"
ATTEMPT=$((ATTEMPT+1))
sudo apt-get install -y $1;
echo ""
CheckPackage $1
else
echo -e "\033[32m [OK]\033[37m"
ATTEMPT=0
fi
}
## INFORMATIVE MESSAGE ABOUT THIS SOFTWARE
clear
@ -117,12 +86,12 @@ CheckPackage itcl3
## DOWNLOAD OR UPDATE THE PIAWARE_BUILDER SOURCE
# Check if the git repository already exists locally.
if [ -d "$BUILDDIR/piaware_builder" ] && [ -d $BUILDDIR/piaware_builder/.git ]; then
if [ -d $PIAWAREDIR ] && [ -d $PIAWAREDIR/.git ]; then
# A directory with a git repository containing the source code exists.
echo -e "\033[33m"
echo "Updating the local piaware_builder git repository..."
echo -e "\033[37m"
cd $BUILDDIR/piaware_builder
cd $PIAWAREDIR
git pull origin master
else
# A directory containing the source code does not exist in the build directory.
@ -130,8 +99,8 @@ else
echo "Cloning the piaware_builder git repository locally..."
echo -e "\033[37m"
git clone https://github.com/flightaware/piaware_builder.git
cd $BUILDDIR/piaware_builder
git checkout tags/v${CURRENTVERSION}
cd $PIAWAREDIR
git checkout ${PIAWAREBRANCH}
fi
## BUILD THE PIAWARE PACKAGE
@ -140,7 +109,7 @@ echo -e "\033[33m"
echo "Building the PiAware package..."
echo -e "\033[37m"
./sensible-build.sh
cd $BUILDDIR/piaware_builder/package
cd $PIAWAREDIR/package
dpkg-buildpackage -b
## INSTALL THE PIAWARE PACKAGE
@ -148,16 +117,11 @@ dpkg-buildpackage -b
echo -e "\033[33m"
echo "Installing the PiAware package..."
echo -e "\033[37m"
### TEMPORARY FIX #########################################################################
# READ THE COMMENT PERTAINING TO THE VARIABLE CURRENTVERSIONNAME AT THE TOP OF THE SCRIPT #
###########################################################################################
#sudo dpkg -i $BUILDDIR/piaware_builder/piaware_${CURRENTVERSION}_*.deb
sudo dpkg -i $BUILDDIR/piaware_builder/piaware_${CURRENTVERSIONNAME}_*.deb
sudo dpkg -i $PIAWAREDIR/piaware_${PIAWAREVERSION}_*.deb
## CHECK THAT THE PACKAGE INSTALLED
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 "\033[31m"
echo "The piaware package did not install properly!"
echo -e "\033[33m"

Wyświetl plik

@ -31,43 +31,14 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
BUILDDIR=${PWD}
## VARIABLES
## DECLARE THE CURRENT VERSIONS OF THE SOFTWARE
BUILDDIR=$PWD
ARMVERSION="3.1.201"
I386VERSION="3.0.2080"
source ../bash/variables.sh
source ../bash/functions.sh
## FUNCTIONS
# Function used to check if a package is install and if not install it.
ATTEMPT=1
function CheckPackage(){
if (( $ATTEMPT > 5 )); then
echo -e "\033[33mSCRIPT HALETED! \033[31m[FAILED TO INSTALL PREREQUISITE PACKAGE]\033[37m"
echo ""
exit 1
fi
printf "\e[33mChecking if the package $1 is installed..."
if [ $(dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
if (( $ATTEMPT > 1 )); then
echo -e "\033[31m [PREVIOUS INSTALLATION FAILED]\033[37m"
echo -e "\033[33mAttempting to Install the package $1 again in 5 seconds (ATTEMPT $ATTEMPT OF 5)..."
sleep 5
else
echo -e "\033[31m [NOT INSTALLED]\033[37m"
echo -e "\033[33mInstalling the package $1..."
fi
echo -e "\033[37m"
ATTEMPT=$((ATTEMPT+1))
sudo apt-get install -y $1;
echo ""
CheckPackage $1
else
echo -e "\033[32m [OK]\033[37m"
ATTEMPT=0
fi
}
## INFORMATIVE MESSAGE ABOUT THIS SOFTWARE
clear
@ -110,9 +81,9 @@ echo -e "\033[33m"
echo "Downloading the Plane Finder ADS-B Client package..."
echo -e "\033[37m"
if [[ `uname -m` == "armv7l" ]]; then
wget http://client.planefinder.net/pfclient_${ARMVERSION}_armhf.deb -O $BUILDDIR/pfclient_${ARMVERSION}_armhf.deb
wget http://client.planefinder.net/pfclient_${PFCLIENTVERSIONARM}_armhf.deb -O $BUILDDIR/pfclient_${PFCLIENTVERSIONARM}_armhf.deb
else
wget http://client.planefinder.net/pfclient_${I386VERSION}_i386.deb -O $BUILDDIR/pfclient_${I386VERSION}_i386.deb
wget http://client.planefinder.net/pfclient_${PFCLIENTVERSIONI386}_i386.deb -O $BUILDDIR/pfclient_${PFCLIENTVERSIONI386}_i386.deb
fi
## INSTALL THE PLANEFINDER ADS-B CLIENT PACKAGE
@ -121,19 +92,19 @@ echo -e "\033[33m"
echo "Installing the Plane Finder ADS-B Client package..."
echo -e "\033[37m"
if [[ `uname -m` == "armv7l" ]]; then
sudo dpkg -i $BUILDDIR/pfclient_${ARMVERSION}_armhf.deb
sudo dpkg -i $BUILDDIR/pfclient_${PFCLIENTVERSIONARM}_armhf.deb
else
if [[ `lsb_release -si` == "Debian" ]]; then
# Force architecture if this is Debian.
sudo dpkg -i --force-architecture $BUILDDIR/pfclient_${I386VERSION}_i386.deb
sudo dpkg -i --force-architecture $BUILDDIR/pfclient_${PFCLIENTVERSIONI386}_i386.deb
else
sudo dpkg -i $BUILDDIR/pfclient_${I386VERSION}_i386.deb
sudo dpkg -i $BUILDDIR/pfclient_${PFCLIENTVERSIONI386}_i386.deb
fi
fi
## CHECK THAT THE PACKAGE INSTALLED
if [ $(dpkg-query -W -f='${Status}' pfclient 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
if [ $(dpkg-query -W -f='${STATUS}' pfclient 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo "\033[31m"
echo "The piaware package did not install properly!"
echo -e "\033[33m"

83
bash/functions.sh 100755
Wyświetl plik

@ -0,0 +1,83 @@
#!/bin/bash
#####################################################################################
# ADS-B FEEDER #
#####################################################################################
# #
# This script is not meant to be executed directly. #
# Instead execute install.sh to begin the installation process. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Copyright (c) 2015 Joseph A. Prochazka #
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
# copies of the Software, and to permit persons to whom the Software is #
# furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in all #
# copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, #
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE #
# SOFTWARE. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#######################################################################
# Detect if a package is installed and if not attempt to install it.
function CheckPackage {
ATTEMPT=1
MAXATTEMPTS=5
WAITTIME=5
while (( $ATTEMPT -le `(($MAXATTEMPTS + 1))` )); do
# If the maximum attempts has been reached...
if [ $ATTEMPT -gt $MAXATTEMPTS ]; then
echo -e "\033[31m"
echo "#########################################"
echo "# INSTALLATION HALTED! #"
echo "# UNABLE TO INSTALL A REQUIRED PACKAGE. #"
echo "#########################################"
echo -e "\033[33m"
echo "The package \"$1\" could not be installed in $MAXATTEMPTS attempts."
echo -e "\033[37m"
exit 1
fi
# Check if the package is already installed.
printf "\033[33mChecking if the package $1 is installed..."
if [ $(dpkg-query -W -f='${STATUS}' $1 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
# If this is not the first attempt at installing this package...
if [ $ATTEMPT -gt 1 ]; then
echo -e "\033[31m [PREVIOUS INSTALLATION FAILED]"
echo -e "\033[33mAttempting to Install the package $1 again in $WAITTIME seconds (ATTEMPT $ATTEMPT OF $MAXATTEMPTS)..."
sleep $WAITTIME
else
echo -e "\033[31m [NOT INSTALLED]"
echo -e "\033[33mInstalling the package $1..."
fi
# Attempt to install the required package.
echo -e "\033[37m"
ATTEMPT=$((ATTEMPT+1))
sudo apt-get install -y $1
echo ""
else
# The package appears to be installed.
echo -e "\033[32m [OK]\033[37m"
break
fi
done
}

Wyświetl plik

@ -31,7 +31,7 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
BUILDDIR="${PWD}/build"
BUILDDIR=$PWD
# Assign the Lighthttpd document root directory to a variable.
RAWDOCUMENTROOT=`/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -p | grep server.document-root`

Wyświetl plik

@ -31,7 +31,7 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
BUILDDIR="${PWD}/build"
BUILDDIR=$PWD
# Assign the Lighthttpd document root directory to a variable.
RAWDOCUMENTROOT=`/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -p | grep server.document-root`

Wyświetl plik

@ -31,38 +31,10 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
SCRIPTDIR=${PWD}
BUILDDIR=$PWD
BASHDIR=$BUILDDIR/../bash
## FUNCTIONS
# Function used to check if a package is install and if not install it.
ATTEMPT=1
function CheckPackage(){
if (( $ATTEMPT > 5 )); then
echo -e "\033[33mSCRIPT HALETED! \033[31m[FAILED TO INSTALL PREREQUISITE PACKAGE]\033[37m"
echo ""
exit 1
fi
printf "\e[33mChecking if the package $1 is installed..."
if [ $(dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
if (( $ATTEMPT > 1 )); then
echo -e "\033[31m [PREVIOUS INSTALLATION FAILED]\033[37m"
echo -e "\033[33mAttempting to Install the package $1 again in 5 seconds (ATTEMPT $ATTEMPT OF 5)..."
sleep 5
else
echo -e "\033[31m [NOT INSTALLED]\033[37m"
echo -e "\033[33mInstalling the package $1..."
fi
echo -e "\033[37m"
ATTEMPT=$((ATTEMPT+1))
sudo apt-get install -y $1;
echo ""
CheckPackage $1
else
echo -e "\033[32m [OK]\033[37m"
ATTEMPT=0
fi
}
source ../bash/functions.sh
clear
@ -93,27 +65,27 @@ CheckPackage rrdtool
echo -e "\033[33m"
echo "Installing homepage..."
echo -e "\033[37m"
chmod +x $SCRIPTDIR/bash/portal/homepage.sh
$SCRIPTDIR/bash/portal/homepage.sh
chmod +x $BASHDIR/portal/homepage.sh
$BASHDIR/portal/homepage.sh
echo -e "\033[33m"
echo "Installing map container..."
echo -e "\033[37m"
chmod +x $SCRIPTDIR/bash/portal/map.sh
$SCRIPTDIR/bash/portal/map.sh
chmod +x $BASHDIR/portal/map.sh
$BASHDIR/portal/map.sh
echo -e "\033[33m"
echo "Installing performance graphs..."
echo -e "\033[37m"
chmod +x $SCRIPTDIR/bash/portal/graphs.sh
$SCRIPTDIR/bash/portal/graphs.sh
chmod +x $BASHDIR/portal/graphs.sh
$BASHDIR/portal/graphs.sh
if [ $(dpkg-query -W -f='${STATUS}' pfclient 2>/dev/null | grep -c "ok installed") -eq 1 ]; then
echo -e "\033[33m"
echo "Installing performance graphs..."
echo -e "\033[37m"
chmod +x $SCRIPTDIR/bash/portal/planefinder.sh
$SCRIPTDIR/bash/portal/planefinder.sh
chmod +x $BASHDIR/portal/planefinder.sh
$BASHDIR/portal/planefinder.sh
fi
echo -e "\033[33m"

Wyświetl plik

@ -31,7 +31,7 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
BUILDDIR="${PWD}/build"
BUILDDIR=$PWD
# Assign the Lighthttpd document root directory to a variable.
RAWDOCUMENTROOT=`/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -p | grep server.document-root`

Wyświetl plik

@ -31,7 +31,7 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
BUILDDIR="${PWD}/build"
BUILDDIR=$PWD
# Assign the Lighthttpd document root directory to a variable.
RAWDOCUMENTROOT=`/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -p | grep server.document-root`

42
bash/variables.sh 100644
Wyświetl plik

@ -0,0 +1,42 @@
#!/bin/bash
#####################################################################################
# ADS-B FEEDER #
#####################################################################################
# #
# This script is not meant to be executed directly. #
# Instead execute install.sh to begin the installation process. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Copyright (c) 2015 Joseph A. Prochazka #
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
# copies of the Software, and to permit persons to whom the Software is #
# furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in all #
# copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, #
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE #
# SOFTWARE. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## SOFTWARE VERSIONS
# FlightAware PiAware
PIAWAREVERSION="2.1-5"
PIAWAREBRANCH="5c77c4924"
# PlaneFinder ADS-B Client
PFCLIENTVERSIONARM="3.1.201"
PFCLIENTVERSIONI386="3.0.2080"

Wyświetl plik

@ -34,49 +34,17 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
##############
## VARIABLES
PIAWAREVERSION="2.1-5-jessie"
PFCLIENTI386VERSION="3.1.201"
PFCLIENTARMVERSION="3.0.2080"
BASEDIR=$PWD
BASHDIR="$BASEDIR/bash"
BUILDDIR="$BASEDIR/build"
SCRIPTDIR=${PWD}
BUILDDIR="$SCRIPTDIR/build"
source $BASHDIR/variables.sh
source $BASHDIR/functions.sh
##############
## FUNCTIONS
# Function used to check if a package is install and if not install it.
ATTEMPT=1
function CheckPackage(){
if (( $ATTEMPT > 5 )); then
echo -e "\033[33mSCRIPT HALETED! \033[31m[FAILED TO INSTALL PREREQUISITE PACKAGE]\033[37m"
echo ""
exit 1
fi
printf "\e[33mChecking if the package $1 is installed..."
if [ $(dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
if (( $ATTEMPT > 1 )); then
echo -e "\033[31m [PREVIOUS INSTALLATION FAILED]\033[37m"
echo -e "\033[33mAttempting to Install the package $1 again in 5 seconds (ATTEMPT $ATTEMPT OF 5)..."
sleep 5
else
echo -e "\033[31m [NOT INSTALLED]\033[37m"
echo -e "\033[33mInstalling the package $1..."
fi
echo -e "\033[37m"
ATTEMPT=$((ATTEMPT+1))
sudo apt-get install -y $1;
echo ""
CheckPackage $1
else
echo -e "\033[32m [OK]\033[37m"
ATTEMPT=0
fi
}
# Download the latest package lists for enabled repositories and PPAs.
function AptUpdate() {
clear
@ -99,34 +67,15 @@ function UpdateOperatingSystem() {
read -p "Press enter to continue..." CONTINUE
}
# Update Raspberry Pi firmware.
function UpdateFirmware() {
clear
CheckPackage rpi-update
echo -e "\033[33m"
echo "Updating Raspberry Pi firmware..."
echo -e "\033[37m"
sudo rpi-update
echo -e "\033[33m"
echo "Your Raspberry Pi firmware is now up to date."
echo "If in fact your firmware was update it is recommended that you restart your device now."
echo "After the reboot execute this script again to enter the installation process once more."
echo -e "\033[37m"
read -p "Would you like to reboot your device now? [y/N] " REBOOT
if [[ $REBOOT =~ ^[Yy]$ ]]; then
sudo reboot
fi
}
# Download, build and then install the dump1090-mutability package.
function InstallDump1090() {
clear
cd $BUILDDIR
echo -e "\033[33mExecuting the dump1090-mutability installation script..."
echo -e "\033[37m"
chmod +x $SCRIPTDIR/bash/decoders/dump1090-mutability.sh
$SCRIPTDIR/bash/decoders/dump1090-mutability.sh
cd $SCRIPTDIR
chmod +x $BASHDIR/decoders/dump1090-mutability.sh
$BASHDIR/decoders/dump1090-mutability.sh
cd $BASEDIR
}
# Download, build and then install the PiAware package.
@ -135,9 +84,9 @@ function InstallPiAware() {
cd $BUILDDIR
echo -e "\033[33mExecuting the PiAware installation script..."
echo -e "\033[37m"
chmod +x $SCRIPTDIR/bash/feeders/piaware.sh
$SCRIPTDIR/bash/feeders/piaware.sh
cd $SCRIPTDIR
chmod +x $BASHDIR/feeders/piaware.sh
$BASHDIR/feeders/piaware.sh
cd $BASEDIR
}
# Download and install the Plane Finder ADS-B Client package.
@ -146,9 +95,9 @@ function InstallPlaneFinder() {
cd $BUILDDIR
echo -e "\033[33mExecuting the Plane Finder ADS-B Client installation script..."
echo -e "\033[37m"
chmod +x $SCRIPTDIR/bash/feeders/planefinder.sh
$SCRIPTDIR/bash/feeders/planefinder.sh
cd $SCRIPTDIR
chmod +x $BASHDIR/feeders/planefinder.sh
$BASHDIR/feeders/planefinder.sh
cd $BASEDIR
}
# Setup the ADS-B Exchange feed.
@ -157,20 +106,20 @@ function InstallAdsbExchange() {
cd $BUILDDIR
echo -e "\033[33mExecuting the ADS-B Exchange installation script..."
echo -e "\033[37m"
chmod +x $SCRIPTDIR/bash/feeders/adsbexchange.sh
$SCRIPTDIR/bash/feeders/adsbexchange.sh
cd $SCRIPTDIR
chmod +x $BASHDIR/bash/feeders/adsbexchange.sh
$BASHDIR/feeders/adsbexchange.sh
cd $BASEDIR
}
# Setup and execute the web portal installation scripts.
function InstallWebPortal() {
clear
cd $SCRIPTDIR
cd $BUILDDIR
echo -e "\033[33mExecuting the web portal installation scripts..."
echo -e "\033[37m"
chmod +x $SCRIPTDIR/bash/portal/install.sh
$SCRIPTDIR/bash/portal/install.sh
cd $SCRIPTDIR
chmod +x $BASHDIR/portal/install.sh
$BASHDIR/portal/install.sh
cd $BASEDIR
}
@ -204,16 +153,6 @@ It is recommended that you update your system before building and/or installing
Update system before installing any ADS-B feeder related software?
EOF
# Message displayed asking to update the Raspberry Pi firmware.
read -d '' UPDATEFIRMWAREFIRST <<"EOF"
This script has detected that this may be a Raspberry Pi. If this is in fact a Raspberry Pi this script can update the system's firmware now as well.
If you choose to update your Raspberry Pi firmware this script will check for the existance of the package rpi-update and install it if it is not install already. After confirming that rpi-update is installed it will be used to update your firmware.
Is this in fact a Raspberry Pi and if so do you want to update
the firmware now? (This will require a reboot.)
EOF
# Message displayed if dump1090-mutability is installed.
read -d '' DUMP1090INSTALLED <<"EOF"
The dump1090-mutability package appears to be installed on your device However...
@ -280,13 +219,6 @@ fi
whiptail --backtitle "$BACKTITLE" --title "Install Operating System Updates" --yesno "$UPDATEFIRST" 10 65
UPDATEOS=$?
# Ask to update the Raspberry Pi firmware.
UPDATEFIRMWARENOW=1
if [[ `uname -m` == "armv7l" ]]; then
whiptail --backtitle "$BACKTITLE" --title "Update Raspberry Pi Firmware" --yesno "$UPDATEFIRMWAREFIRST" 10 65
UPDATEFIRMWARENOW=$?
fi
## DUMP1090-MUTABILITY CHECK
DUMP1090CHOICE=1
@ -332,12 +264,12 @@ if [ $(dpkg-query -W -f='${STATUS}' pfclient 2>/dev/null | grep -c "ok installed
FEEDERLIST=("${FEEDERLIST[@]}" 'Plane Finder ADS-B Client' '' OFF)
else
# Set version depending on the device architecture.
PFCLIENTVERSION=$PFCLIENTARMVERSION
PFCLIENTVERSION=$PFCLIENTVERSIONARM
## The i386 version even though labeled as 3.1.201 is in fact reported as 3.0.2080.
## So for now we will skip the architecture check and use the ARM version variable for both.
#if [[ `uname -m` != "armv7l" ]]; then
# PFCLIENTVERSION=$PFCLIENTI386VERSION
# PFCLIENTVERSION=$PFCLIENTVERSIONI386
#fi
# Check if a newer version can be installed.
@ -372,7 +304,7 @@ DOINSTALLWEBPORTAL=$?
## CONFIRMATION
# Check if anything is to be done before moving on.
if [ $UPDATEOS = 1 ] && [ $UPDATEFIRMWARENOW = 1 ] && [ $DUMP1090CHOICE = 1 ] && [ $DOINSTALLWEBPORTAL = 1 ] && [ ! -s FEEDERCHOICES ]; then
if [ $UPDATEOS = 1 ] && [ $DUMP1090CHOICE = 1 ] && [ $DOINSTALLWEBPORTAL = 1 ] && [ ! -s FEEDERCHOICES ]; then
whiptail --backtitle "$BACKTITLE" --title "Nothing to be done" --msgbox "$NOTHINGTODO" 10 65
echo -e "\033[31m"
@ -389,7 +321,7 @@ fi
declare CONFIRMATION
# If the user decided to install updates...
if [ $UPDATEOS = 0 ] || [ $UPDATEFIRMWARENOW = 0 ]; then
if [ $UPDATEOS = 0 ]; then
CONFIRMATION="The following actions will be performed:\n"
if [ $UPDATEOS = 0 ]; then
@ -397,10 +329,6 @@ if [ $UPDATEOS = 0 ] || [ $UPDATEFIRMWARENOW = 0 ]; then
CONFIRMATION="${CONFIRMATION}\n * Operating system updates will be applied."
fi
if [ $UPDATEFIRMWARENOW = 0 ]; then
# Firmware update message.
CONFIRMATION="${CONFIRMATION}\n * Raspberry Pi firmware updates will be applied."
fi
CONFIRMATION="${CONFIRMATION}\n"
fi
@ -474,10 +402,6 @@ if [ $UPDATEOS = 0 ]; then
UpdateOperatingSystem
fi
if [ $UPDATEFIRMWARENOW = 0 ]; then
UpdateFirmware
fi
## Mode S decoder.
if [ $DUMP1090CHOICE = 0 ]; then