Began shell script cleanup.

pull/222/head
Joe Prochazka 2016-09-01 17:06:18 -04:00
rodzic 5726025300
commit 59b7ee07cb
4 zmienionych plików z 129 dodań i 122 usunięć

Wyświetl plik

@ -9,7 +9,7 @@
# # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # #
# Copyright (c) 2015 Joseph A. Prochazka # # Copyright (c) 2015-2016 Joseph A. Prochazka #
# # # #
# Permission is hereby granted, free of charge, to any person obtaining a copy # # Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal # # of this software and associated documentation files (the "Software"), to deal #
@ -31,49 +31,39 @@
# # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
BUILDDIR=$PWD ### VARIABLES
DUMP1090DIR="$BUILDDIR/dump1090"
source ../bash/functions.sh PROJECTROOTDIRECTORY="$PWD"
BASHDIRECTORY="$PROJECTROOTDIRECTORY/bash"
BUILDDIRECTORY="$PROJECTROOTDIRECTORY/build"
DUMP1090BUILDDIRECTORY="$PROJECTROOTDIRECTORY/build/dump1090"
### INCLUDE EXTERNAL SCRIPTS
source $BASHDIRECTORY/variables.sh
source $BASHDIRECTORY/functions.sh
## BEGIN SETUP
clear clear
echo -e "\n\e[91m THE ADS-B RECIEVER PROJECT VERSION $PROJECTVERSION"
echo -e "\033[31m"
echo "-------------------------------------------"
echo " Now ready to install dump1090-mutability."
echo "-------------------------------------------"
echo -e "\033[33mDump 1090 is a Mode S decoder specifically designed for RTLSDR devices."
echo "Dump1090-mutability is a fork of MalcolmRobb's version of dump1090 that adds new"
echo "functionality and is designed to be built as a Debian/Raspbian package."
echo "" echo ""
echo "https://github.com/mutability/dump1090" echo -e "\e[92m Setting up dump1090-mutability..."
echo -e "\033[37m" echo -e "\e[93m------------------------------------------------------------------------------\e[96m"
echo ""
echo " Dump 1090 is a Mode S decoder specifically designed for RTLSDR devices."
echo " Dump1090-mutability is a fork of MalcolmRobb's version of dump1090 that adds"
echo " new functionality and is designed to be built as a Debian/Raspbian package."
echo ""
echo " https://github.com/mutability/dump1090"
echo -e "\e[39m"
read -p "Press enter to continue..." CONTINUE read -p "Press enter to continue..." CONTINUE
## ASK WHICH WEB SERVER TO INSTALL
# Commented out temporarily until choice has been added to
# the portal installations scipt as well.
#echo -e "\033[31m"
#echo "Select Web Server"
#echo -e "\033[33m"
#echo "Select the web server you wish to use."
#echo "Currently Lighttpd is the recommended web server."
#echo ""
#echo " 1) Lighttpd"
#echo " 2) Nginx"
#echo -e "\033[37m"
#read -p "Which web server do you wish to use? [1] " WEBSERVER
# For now we will force Lighttpd as the web server chosen.
WEBSERVER=1
## CHECK FOR PREREQUISITE PACKAGES ## CHECK FOR PREREQUISITE PACKAGES
echo -e "\033[33m" echo ""
echo "Installing packages needed to build and fulfill dependencies..." echo -e "\e[95m Installing packages needed to build and fulfill dependencies...\e[97m"
echo -e "\033[37m" echo ""
CheckPackage git CheckPackage git
CheckPackage curl CheckPackage curl
CheckPackage build-essential CheckPackage build-essential
@ -83,49 +73,67 @@ CheckPackage rtl-sdr
CheckPackage librtlsdr-dev CheckPackage librtlsdr-dev
CheckPackage libusb-1.0-0-dev CheckPackage libusb-1.0-0-dev
CheckPackage pkg-config CheckPackage pkg-config
CheckPackage lighttpd
if [[ $WEBSERVER != "2" ]]; then
CheckPackage lighttpd
else
CheckPackage nginx
fi
CheckPackage fakeroot CheckPackage fakeroot
## DOWNLOAD OR UPDATE THE DUMP1090-MUTABILITY SOURCE ## DOWNLOAD OR UPDATE THE DUMP1090-MUTABILITY SOURCE
# Check if the git repository already exists locally. echo ""
if [ -d $DUMP1090DIR ] && [ -d $DUMP1090DIR/.git ]; then echo -e "\e[95m Prepare the dump1090-mutability Git repository...\e[97m"
# A directory with a git repository containing the source code exists. echo ""
echo -e "\033[33m" if [ -d $DUMP1090BUILDDIRECTORY ] && [ -d $DUMP1090BUILDDIRECTORY/.git ]; then
echo "Updating the local dump1090-mutability git repository..." # A directory with a git repository containing the source code already exists.
echo -e "\033[37m" echo -e "\e[94m Entering the dump1090-mutability git repository directory...\e[97m"
cd $DUMP1090DIR cd $DUMP1090BUILDDIRECTORY
git pull origin master echo -e "\e[94m Updating the local dump1090-mutability git repository...\e[97m"
echo ""
git pull
else else
# A directory containing the source code does not exist in the build directory. # A directory containing the source code does not exist in the build directory.
echo -e "\033[33m" echo -e "\e[94m Entering the ADS-B Receiver Project build directory...\e[97m"
echo "Cloning the dump1090-mutability git repository locally..." cd $BUILDDIRECTORY
echo -e "\033[37m" echo -e "\e[94m Cloning the dump1090-mutability git repository locally...\e[97m"
echo ""
git clone https://github.com/mutability/dump1090.git git clone https://github.com/mutability/dump1090.git
echo ""
fi fi
## BUILD THE DUMP1090-MUTABILITY PACKAGE ## BUILD THE DUMP1090-MUTABILITY PACKAGE
echo -e "\033[33m" echo ""
echo "Building the dump1090-mutability package..." echo -e "\e[95m Building the dump1090-mutability package...\e[97m"
echo -e "\033[37m" echo ""
cd $DUMP1090DIR if [ ! $PWD = $DUMP1090BUILDDIRECTORY ]; then
echo -e "\e[94m Entering the dump1090-mutability git repository directory...\e[97m"
cd $DUMP1090BUILDDIRECTORY
fi
echo -e "\e[94m Building the dump1090-mutability package...\e[97m"
echo ""
dpkg-buildpackage -b dpkg-buildpackage -b
## INSTALL THE DUMP1090-MUTABILITY PACKAGE ## INSTALL THE DUMP1090-MUTABILITY PACKAGE
echo -e "\033[33m" echo ""
echo "Installing the dump1090-mutability package..." echo -e "\e[95m Installing the dump1090-mutability package...\e[97m"
echo -e "\033[37m" echo ""
cd $BUILDDIR echo -e "\e[94m Entering the ADS-B Receiver Project build directory...\e[97m"
cd $BUILDDIRECTORY
echo -e "\e[94m Installing the dump1090-mutability package......\e[97m"
echo ""
sudo dpkg -i dump1090-mutability_1.15~dev_*.deb sudo dpkg -i dump1090-mutability_1.15~dev_*.deb
#########################
echo ""
echo -e "\e[93m------------------------------------------------------------------------------"
echo -e "\e[92m Dump1090-mutability setup is complete.\e[39m"
echo -e "\e[97m"
cd $PROJECTROOTDIRECTORY
exit 0
#########################
## CHECK THAT THE PACKAGE INSTALLED ## 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

Wyświetl plik

@ -43,39 +43,38 @@ function CheckPackage {
# If the maximum attempts has been reached... # If the maximum attempts has been reached...
if [ $ATTEMPT -gt $MAXATTEMPTS ]; then if [ $ATTEMPT -gt $MAXATTEMPTS ]; then
echo -e "\033[31m" echo ""
echo "#########################################" echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m"
echo "# INSTALLATION HALTED! #" echo -e " UNABLE TO INSTALL A REQUIRED PACKAGE."
echo "# UNABLE TO INSTALL A REQUIRED PACKAGE. #" echo -e " SETUP HAS BEEN TERMINATED!"
echo "#########################################" echo ""
echo -e "\033[33m" echo -e "\e[93mThe package \"$1\" could not be installed in $MAXATTEMPTS attempts.\e[39m"
echo "The package \"$1\" could not be installed in $MAXATTEMPTS attempts." echo ""
echo -e "\033[37m"
exit 1 exit 1
fi fi
# Check if the package is already installed. # Check if the package is already installed.
printf "\033[33mChecking if the package $1 is installed..." printf "\e[94m Checking if the package $1 is installed..."
if [ $(dpkg-query -W -f='${STATUS}' $1 2>/dev/null | grep -c "ok installed") -eq 0 ]; then 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 this is not the first attempt at installing this package...
if [ $ATTEMPT -gt 1 ]; then if [ $ATTEMPT -gt 1 ]; then
echo -e "\033[31m [PREVIOUS INSTALLATION FAILED]" echo -e "\e[91m \e[5m[INSTALLATION ATTEMPT FAILED]\e[25m"
echo -e "\033[33mAttempting to Install the package $1 again in $WAITTIME seconds (ATTEMPT $ATTEMPT OF $MAXATTEMPTS)..." echo -e "\e[94m Attempting to Install the package $1 again in $WAITTIME seconds (ATTEMPT $ATTEMPT OF $MAXATTEMPTS)..."
sleep $WAITTIME sleep $WAITTIME
else else
echo -e "\033[31m [NOT INSTALLED]" echo -e "\e[91m [NOT INSTALLED]"
echo -e "\033[33mInstalling the package $1..." echo -e "\e[94m Installing the package $1..."
fi fi
# Attempt to install the required package. # Attempt to install the required package.
echo -e "\033[37m" echo -e "\e[97m"
ATTEMPT=$((ATTEMPT+1)) ATTEMPT=$((ATTEMPT+1))
sudo apt-get install -y $1 sudo apt-get install -y $1
echo "" echo -e "\e[39m"
else else
# The package appears to be installed. # The package appears to be installed.
echo -e "\033[32m [OK]\033[37m" echo -e "\e[92m [OK]\e[39m"
break break
fi fi
done done

Wyświetl plik

@ -33,6 +33,9 @@
## SOFTWARE VERSIONS ## SOFTWARE VERSIONS
# The ADS-B Receiver Project
PROJECTVERSION="2.1.1"
# FlightAware PiAware # FlightAware PiAware
PIAWAREVERSION="3.0.5" PIAWAREVERSION="3.0.5"

Wyświetl plik

@ -12,7 +12,7 @@
# # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # #
# Copyright (c) 2015 Joseph A. Prochazka # # Copyright (c) 2015-2016 Joseph A. Prochazka #
# # # #
# Permission is hereby granted, free of charge, to any person obtaining a copy # # Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal # # of this software and associated documentation files (the "Software"), to deal #
@ -36,64 +36,61 @@
## VARIABLES ## VARIABLES
BASEDIR=$PWD PROJECTROOTDIRECTORY="$PWD"
BASHDIR="$BASEDIR/bash" BASHDIRECTORY="$PWD/bash"
BUILDDIR="$BASEDIR/build" BUILDDIRECTORY="$PWD/build"
source $BASHDIR/variables.sh source $BASHDIRECTORY/variables.sh
source $BASHDIR/functions.sh source $BASHDIRECTORY/functions.sh
## CHECK IF FIRST RUN USING IMAGE ## CHECK IF THIS IS THE FIRST RUN USING THE IMAGE RELEASE
if [ -f $BASEDIR/image ]; then
# Execute image setup script.
chmod +x $BASHDIR/image.sh
$BASHDIR/image.sh
# Exit scripts once the the image setup script has completed.
echo -e "\033[32m"
echo "Image setup complete."
echo -e "\033[33m"
echo "At any time you can execute install.sh to add additional features"
echo "or update existing packages installed on this device."
echo -e "\033[37m"
if [ -f $PROJECTROOTDIRECTORY/image ]; then
# Execute image setup script..
chmod +x $BASHDIRECTORY/image.sh
$BASHDIRECTORY/image.sh
exit 0 exit 0
fi fi
## FUNCTIONS ## FUNCTIONS
# Download the latest package lists for enabled repositories and PPAs. # UPDATE REPOSITORY PACKAGE LISTS.
function AptUpdate() { function AptUpdate() {
clear clear
echo -e "\033[33m" echo -e "\n\e[91m THE ADS-B RECIEVER PROJECT VERSION $PROJECTVERSION"
echo "Downloading latest package lists for enabled repositories and PPAs..." echo ""
echo -e "\033[37m" echo -e "\e[92m Downloading the latest package lists for all enabled repositories and PPAs..."
echo -e "\e[93m------------------------------------------------------------------------------------\e[97m"
echo ""
sudo apt-get update sudo apt-get update
} echo ""
echo -e "\e[93m------------------------------------------------------------------------------------"
# Update the operating system. echo -e "\e[92m Finished downloading and updating package lists.\e[39m"
function UpdateOperatingSystem() { echo ""
clear
echo -e "\033[33m"
echo "Downloading and installing the latest updates for your operating system..."
echo -e "\033[37m"
sudo apt-get -y upgrade
echo -e "\033[33m"
echo "Your system should now be up to date."
echo -e "\033[37m"
read -p "Press enter to continue..." CONTINUE read -p "Press enter to continue..." CONTINUE
} }
# Download, build and then install the dump1090-mutability package. # UPDATE THE OPERATING SYSTEM.
function InstallDump1090() { function UpdateOperatingSystem() {
clear clear
cd $BUILDDIR echo -e "\n\e[91m THE ADS-B RECIEVER PROJECT VERSION $PROJECTVERSION"
echo -e "\033[33mExecuting the dump1090-mutability installation script..." echo ""
echo -e "\033[37m" echo -e "\e[92m Downloading and installing the latest updates for your operating system..."
chmod +x $BASHDIR/decoders/dump1090-mutability.sh echo -e "\e[93m---------------------------------------------------------------------------------\e[97m"
$BASHDIR/decoders/dump1090-mutability.sh echo ""
cd $BASEDIR sudo apt-get -y upgrade
echo ""
echo -e "\e[93m---------------------------------------------------------------------------------"
echo -e "\e[92m Your operating system should now be up to date.\e[39m"
echo ""
read -p "Press enter to continue..." CONTINUE
}
# DUMP1090-MUTABILITY
function InstallDump1090() {
# Execute the dump1090-mutability setup script.
chmod +x $BASHDIRECTORY/decoders/dump1090-mutability.sh
$BASHDIRECTORY/decoders/dump1090-mutability.sh
} }
# Download and build dump978. # Download and build dump978.