Ability to log output using -l option.

pull/275/head^2
Joe Prochazka 2016-12-08 17:10:13 -05:00
rodzic 956001ae89
commit 6149b19480
4 zmienionych plików z 457 dodań i 131 usunięć

177
bash/init.sh 100755
Wyświetl plik

@ -0,0 +1,177 @@
#!/bin/bash
#####################################################################################
# ADS-B RECEIVER #
#####################################################################################
# #
# A set of scripts created to automate the process of installing the software #
# needed to setup a Mode S decoder as well as feeders which are capable of #
# sharing your ADS-B results with many of the most popular ADS-B aggregate sites. #
# #
# Project Hosted On GitHub: https://github.com/jprochazka/adsb-receiver #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Copyright (c) 2015-2016 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. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## VARIABLES
PROJECTBRANCH="master"
PROJECTROOTDIRECTORY="$PWD"
BASHDIRECTORY="$PROJECTROOTDIRECTORY/bash"
BUILDDIRECTORY="$PROJECTROOTDIRECTORY/build"
## INCLUDE EXTERNAL SCRIPTS
source $BASHDIRECTORY/functions.sh
## MORE VARIABLES
export ADSB_PROJECTTITLE="The ADS-B Receiver Project Installer"
TERMINATEDMESSAGE=" \e[91m ANY FURTHER SETUP AND/OR INSTALLATION REQUESTS HAVE BEEN TERMINIATED\e[39m"
## CHECK IF THIS IS THE FIRST RUN USING THE IMAGE RELEASE
if [ -f $PROJECTROOTDIRECTORY/image ]; then
# Execute image setup script..
chmod +x $BASHDIRECTORY/image.sh
$BASHDIRECTORY/image.sh
if [ $? -ne 0 ]; then
echo ""
echo -e $TERMINATEDMESSAGE
echo ""
exit 1
fi
exit 0
fi
## FUNCTIONS
# UPDATE REPOSITORY PACKAGE LISTS
function AptUpdate() {
clear
echo -e "\n\e[91m $ADSB_PROJECTTITLE"
echo ""
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
echo ""
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
echo -e "\e[92m Finished downloading and updating package lists.\e[39m"
echo ""
read -p "Press enter to continue..." CONTINUE
}
function CheckPrerequisites() {
clear
echo -e "\n\e[91m $ADSB_PROJECTTITLE"
echo ""
echo -e "\e[92m Checking to make sure the whiptail and git packages are installed..."
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[97m"
echo ""
CheckPackage whiptail
CheckPackage git
echo ""
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
echo -e "\e[92m The whiptail and git packages are installed.\e[39m"
echo ""
read -p "Press enter to continue..." CONTINUE
}
function UpdateRepository() {
## UPDATE THIS REPOSITORY
clear
echo -e "\n\e[91m $ADSB_PROJECTTITLE"
echo ""
echo -e "\e[92m Pulling the latest version of the ADS-B Receiver Project repository..."
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[97m"
echo ""
echo -e "\e[94m Switching to branch $PROJECTBRANCH...\e[97m"
echo ""
git checkout $PROJECTBRANCH
echo ""
echo -e "\e[94m Pulling the latest git repository...\e[97m"
echo ""
git pull
echo ""
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
echo -e "\e[92m Finished pulling the latest version of the ADS-B Receiver Project repository....\e[39m"
echo ""
read -p "Press enter to continue..." CONTINUE
}
# UPDATE THE OPERATING SYSTEM
function UpdateOperatingSystem() {
clear
echo -e "\n\e[91m $ADSB_PROJECTTITLE"
echo ""
echo -e "\e[92m Downloading and installing the latest updates for your operating system..."
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[97m"
echo ""
sudo apt-get -y dist-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
}
AptUpdate
CheckPrerequisites
UpdateRepository
## DISPLAY WELCOME SCREEN
## ASK IF OPERATING SYSTEM SHOULD BE UPDATED
if (whiptail --backtitle "$ADSB_PROJECTTITLE" --title "Operating System Updates" --yesno "It is recommended that you update your system before building and/or installing any ADS-B receiver related packages. This script can do this for you at this time if you like.\n\nWould you like to update your operating system now?" 11 78) then
UpdateOperatingSystem
fi
## EXECUTE BASH/MAIN.SH
chmod +x $BASHDIRECTORY/main.sh
$BASHDIRECTORY/main.sh
if [ $? -ne 0 ]; then
echo -e $TERMINATEDMESSAGE
echo ""
exit 1
fi
## INSTALLATION COMPLETE
# Display the installation complete message box.
whiptail --backtitle "$ADSB_PROJECTTITLE" --title "Software Installation Complete" --msgbox "INSTALLATION COMPLETE\n\nDO NOT DELETE THIS DIRECTORY!\n\nFiles needed for certain items to run properly are contained within this directory. Deleting this directory may result in your receiver not working properly.\n\nHopefully, these scripts and files were found useful while setting up your ADS-B Receiver. Feedback regarding this software is always welcome. If you have any issues or wish to submit feedback, feel free to do so on GitHub.\n\nhttps://github.com/jprochazka/adsb-receiver" 20 65
# Unset any exported variables.
unset ADSB_PROJECTTITLE
# Remove the FEEDERCHOICES file created by whiptail.
rm -f FEEDERCHOICES
echo -e "\033[32m"
echo "Installation complete."
echo -e "\033[37m"
exit 0

248
example.config 100644
Wyświetl plik

@ -0,0 +1,248 @@
#!/bin/bash
#####################################################################################
# ADS-B RECEIVER #
#####################################################################################
# #
# 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. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## ENABLE/DISABLE
# If set to "true" when install.sh is executed the scripts will run headlessly
# without the need for any intervention unless required by a third party app.
AUTOMATED_INSTALLATION_ENABLED="false"
## RECEIVER AND OPERATING SYSTEM
# Allow updates the operating system software installed on your device.
UPDATE_OS="true"
# Specify the receivers latitude and longitude as well as its altitude. This
# information can be obtained from https://www.swiftbyte.com/toolbox/geocode by
# simply supplying an address for this receiver.
RECEIVER_LATITUDE="41.3683798"
RECEIVER_LONGITUDE="-82.1076486"
RECIEVER_ALTITUDE="224"
## DECODERS
# ---------------------------------------------------------------------------------
# DUMP1090
# ---------------------------------------------------------------------------------
#
# One of two dump1090 forks must be installed by these scripts. You are required to
# specify one of the compatably forks in order to complete setup. The two available
# options at this time are the following:
#
# mutability : dump1090-mutability : https://github.com/mutability/dump1090
# fa : dump1090-fa : https://github.com/flightaware/dump1090
#
# If dump1090-fa (fa) is selected PiAware must be installed as
# well in order for dump1090-fa to run properly.
DUMP1090_FORK="mutability"
# Some setups will require you to specify the USB device dump1090 will be using.
# In particular when you are setting up more than one decoder on a single device.
# If you are only running the dump1090 decoder and not in cujunction with say
# dump978 on the same device then it is safe to leave this variable empty.
DUMP1090_USB_DEVICE=""
# OPTIONAL: You can optionally specify a Bing Maps API key in order to use maps
# provided by the Bing Maps service within the dump1090 map page. You can sign up
# for a Bing Maps API key at https://www.bingmapsportal.com.
DUMP1090_BING_MAPS_KEY=""
# OPTIONAL: You can optionally specify a Mapzen API key in order to use maps
# provided by the Mapzen Maps service within the dump1090 map page. You can sign up
# for a Mapzen API key at https://mapzen.com.
DUMP1090_MAPZEN_KEY=""
# OPTIONAL: Maximum range rings can be added to the dump109 map usings data
# obtained from Heywhatsthat.com. You will need to generate a new panarama for
# the receivers location before begining the installation. Note that the ability
# to download the JSON file making up the rings may expire over time on the
# Heywhatsthat.com website.
DUMP1090_HEYWHATSTHAT_INSTALL="false"
# In order to add these rings to your dump1090 map you will first need to visit
# http://www.heywhatsthat.com and generate a new panarama centered on the location
# of your receiver. You will need to supply the view id which is the series of
# letters and/or numbers after "?view=" in the URL located near the top left hand
# corner of the page the panarama is displayed.
DUMP1090_HEYWHATSTHAT_ID=""
# You can speicify the distances to display the Heywhatsthat.com maximum range
# rings in meters be setting the following variables.
DUMP1090_HAYWHATSTHAT_RING1="3048"
DUMP1090_HAYWHATSTHAT_RING2="12192"
# MUTABILITY ONLY: You can specify if dump1090-mutability will be allowed to listen
# on all IP addresses assigned to the device or only on the loopback address.'
DUMP1090_BIND_TO_ALL_IPS="true"
# MUTABILITY ONLY: You can specify the unit of measure used by dump1090-mutability.
# This can be set to either "metric" or "imperial".
DUMP1090_UNIT_OF_MEASURMENT="imperial"
# ---------------------------------------------------------------------------------
# DUMP978
# ---------------------------------------------------------------------------------
DUMP978_INSTALL="false"
# When setting up dump978 along with dump1090 on the same device you will be
# required specify the USB device dump1090 as well as dump978 will be using.
DUMP978_USB_DEVICE="1"
# ---------------------------------------------------------------------------------
# RTLSDR-OGN
# ---------------------------------------------------------------------------------
RTLSDROGN_INSTALL="false"
## FEEDERS
# ---------------------------------------------------------------------------------
# ADS-B Exchange
# ---------------------------------------------------------------------------------
ADSBEXCHANGE_INSTALL="false"
# The receiver name should be a unique name specific to this receiver which you can
# use to identify your receiver on the ADS-B Exchange MLAT status pages.
ADSBEXCHANGE_RECEIVER_NAME=""
# ---------------------------------------------------------------------------------
# FLIGHTRADAR24 FEEDER CLIENT
# ---------------------------------------------------------------------------------
#
# The Flightradar24 Feeder Client requires the user to interact physically with the
# device during installation. If you are to choose to set this installation option
# to "true" then the insteractive installation mode will be automatically enabled
# for the entire installation process.
FLIGHTRADAR24_INSTALL="false"
# ---------------------------------------------------------------------------------
# PIAWARE
# ---------------------------------------------------------------------------------
PIAWARE_INSTALL="false"
# The variables PIAWARE_FLIGHTAWARE_LOGIN and PIAWARE_FLIGHTAWARE_PASSWORD are
# optional and may be left empty. If you decide to leave these values empty you
# will need to manual claim this device as your on FlightAwares website.
# Information on claiming your device can be found at the following address:
#
# http://flightaware.com/adsb/piaware/claim
PIAWARE_FLIGHTAWARE_LOGIN=""
PIAWARE_FLIGHTAWARE_PASSWORD=""
# ---------------------------------------------------------------------------------
# PLANEFINDER ADS-B CLIENT
# ---------------------------------------------------------------------------------
#
# After setup has completed the Plane Finder ADS-B Client should be installed and
# running however this script is only capable of installing the Plane Finder ADS-B
# Client. There are still a few steps left which you must manually do through the
# Plane Finder ADS-B Client itself after the setup process is complete.
#
# Visit the following URL: http://127.0.0.1:30053
#
# Use the following settings when asked for them.
#
# Data Format: Beast
# Tcp Address: 127.0.0.1
# Tcp Port: 30005
PLANEFINDER_INSTALL="false"
## WEB PORTAL
# ---------------------------------------------------------------------------------
#
# In order to complete the portal setup process you will still be required to visit
# the following URL in your favorite web browser: http://127.0.0.1/install/
WEBPORTAL_INSTALL="true"
WEBPORTAL_ADVANCED="false"
# If WEBPORTAL_ADVANCED is set to "true" the variable WEBPORTAL_DATABASE_ENGINE
# must be set as well. There are currently two database engine options available.
#
# mysql : MySQL : http://www.mysql.com/
# sqlite : SQLite : http://sqlite.org/
WEBPORTAL_DATABASE_ENGINE=""
# If you are using MySQL as your database engine you must specify if the database
# server will be hosted locally on this device or at a remote location.
WEBPORTAL_MYSQL_SERVER_LOCAL=""
# If you are using MySQL you will also need to specify the hostname or address of
# the MySQL server you are going to use. If the MySQL server will be running
# locally on this device then the WEBPORTAL_MYSQL_SERVER_HOSTNAME value should
# be set to "localhost".
WEBPORTAL_MYSQL_SERVER_HOSTNAME="localhost"
# If the database to be used by the portal already exists set you will want to set
# the value of the variable WEBPORTAL_DATABASE_EXISTS to "true" in order to skip
# the database creation process.
WEBPORTAL_DATABASE_EXISTS=""
# If the database which will be used by the portal does not exist you will need to
# supply administrative credentials the script can use to log into the database
# eengine in order to create the database.
WEBPORTAL_DATABASE_ADMIN_USER=""
WEBPORTAL_DATABASE_ADMIN_PASSWORD=""
# You will need to supply both the database name as well as the credentials needed
# to log into the database server even if the database does or does not exist yet.
WEBPORTAL_DATABASE_NAME=""
WEBPORTAL_DATABASE_USER=""
WEBPORTAL_DATABASE_PASSWORD=""

Wyświetl plik

@ -36,143 +36,43 @@
## VARIABLES
PROJECTBRANCH="master"
PROJECTROOTDIRECTORY="$PWD"
BASHDIRECTORY="$PROJECTROOTDIRECTORY/bash"
BUILDDIRECTORY="$PROJECTROOTDIRECTORY/build"
LOGDIRECTORY="$PROJECTROOTDIRECTORY/logs"
## INCLUDE EXTERNAL SCRIPTS
## CHECK FOR OPTIONS AND ARGUMENTS
source $BASHDIRECTORY/functions.sh
while test $# -gt 0; do
case "$1" in
-h|--help)
# Display a help message.
echo "Usage: install.sh [OPTIONS] [ARGUMENTS]"
echo ""
echo "Option GNU long option Meaning"
echo "-h --help Shows this message."
echo "-l --log-output Logs all output to a file in the logs directory."
exit 0
;;
-l|--log-output)
# Enable logging to a log file.
ENABLE_LOGGING="true"
shift
;;
*)
# No options were set so exit.
break
;;
esac
done
## MORE VARIABLES
export ADSB_PROJECTTITLE="The ADS-B Receiver Project Installer"
TERMINATEDMESSAGE=" \e[91m ANY FURTHER SETUP AND/OR INSTALLATION REQUESTS HAVE BEEN TERMINIATED\e[39m"
## CHECK IF THIS IS THE FIRST RUN USING THE IMAGE RELEASE
if [ -f $PROJECTROOTDIRECTORY/image ]; then
# Execute image setup script..
chmod +x $BASHDIRECTORY/image.sh
$BASHDIRECTORY/image.sh
if [ $? -ne 0 ]; then
echo ""
echo -e $TERMINATEDMESSAGE
echo ""
exit 1
fi
exit 0
chmod +x $BASHDIRECTORY/init.sh
if [ ! -z $ENABLE_LOGGING ] && [ $ENABLE_LOGGING = "true" ]; then
# Execute init.sh logging all output to the log drectory as the file name specified.
$BASHDIRECTORY/init.sh 2>&1 | tee -a "$LOGDIRECTORY/install_$(date +"%m_%d_%Y_%H_%M_%S").log"
else
# Execute init.sh without logging any output to the log directory.
$BASHDIRECTORY/init.sh
fi
## FUNCTIONS
# UPDATE REPOSITORY PACKAGE LISTS
function AptUpdate() {
clear
echo -e "\n\e[91m $ADSB_PROJECTTITLE"
echo ""
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
echo ""
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
echo -e "\e[92m Finished downloading and updating package lists.\e[39m"
echo ""
read -p "Press enter to continue..." CONTINUE
}
function CheckPrerequisites() {
clear
echo -e "\n\e[91m $ADSB_PROJECTTITLE"
echo ""
echo -e "\e[92m Checking to make sure the whiptail and git packages are installed..."
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[97m"
echo ""
CheckPackage whiptail
CheckPackage git
echo ""
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
echo -e "\e[92m The whiptail and git packages are installed.\e[39m"
echo ""
read -p "Press enter to continue..." CONTINUE
}
function UpdateRepository() {
## UPDATE THIS REPOSITORY
clear
echo -e "\n\e[91m $ADSB_PROJECTTITLE"
echo ""
echo -e "\e[92m Pulling the latest version of the ADS-B Receiver Project repository..."
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[97m"
echo ""
echo -e "\e[94m Switching to branch $PROJECTBRANCH...\e[97m"
echo ""
git checkout $PROJECTBRANCH
echo ""
echo -e "\e[94m Pulling the latest git repository...\e[97m"
echo ""
git pull
echo ""
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
echo -e "\e[92m Finished pulling the latest version of the ADS-B Receiver Project repository....\e[39m"
echo ""
read -p "Press enter to continue..." CONTINUE
}
# UPDATE THE OPERATING SYSTEM
function UpdateOperatingSystem() {
clear
echo -e "\n\e[91m $ADSB_PROJECTTITLE"
echo ""
echo -e "\e[92m Downloading and installing the latest updates for your operating system..."
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[97m"
echo ""
sudo apt-get -y dist-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
}
AptUpdate
CheckPrerequisites
UpdateRepository
## DISPLAY WELCOME SCREEN
## ASK IF OPERATING SYSTEM SHOULD BE UPDATED
if (whiptail --backtitle "$ADSB_PROJECTTITLE" --title "Operating System Updates" --yesno "It is recommended that you update your system before building and/or installing any ADS-B receiver related packages. This script can do this for you at this time if you like.\n\nWould you like to update your operating system now?" 11 78) then
UpdateOperatingSystem
fi
## EXECUTE BASH/MAIN.SH
chmod +x $BASHDIRECTORY/main.sh
$BASHDIRECTORY/main.sh
if [ $? -ne 0 ]; then
echo -e $TERMINATEDMESSAGE
echo ""
exit 1
fi
## INSTALLATION COMPLETE
# Display the installation complete message box.
whiptail --backtitle "$ADSB_PROJECTTITLE" --title "Software Installation Complete" --msgbox "INSTALLATION COMPLETE\n\nDO NOT DELETE THIS DIRECTORY!\n\nFiles needed for certain items to run properly are contained within this directory. Deleting this directory may result in your receiver not working properly.\n\nHopefully, these scripts and files were found useful while setting up your ADS-B Receiver. Feedback regarding this software is always welcome. If you have any issues or wish to submit feedback, feel free to do so on GitHub.\n\nhttps://github.com/jprochazka/adsb-receiver" 20 65
# Unset any exported variables.
unset ADSB_PROJECTTITLE
# Remove the FEEDERCHOICES file created by whiptail.
rm -f FEEDERCHOICES
echo -e "\033[32m"
echo "Installation complete."
echo -e "\033[37m"
exit 0

Wyświetl plik

@ -0,0 +1 @@
Placeholder file to make sure the logs folder is created