adsb-receiver/install.sh

135 wiersze
5.6 KiB
Bash
Czysty Zwykły widok Historia

2015-11-04 04:48:08 +00:00
#!/bin/bash
#####################################################################################
# ADS-B RECEIVER #
2015-11-04 04:48:08 +00:00
#####################################################################################
# #
# 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 #
2015-11-04 04:48:08 +00:00
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
2016-09-01 21:06:18 +00:00
# Copyright (c) 2015-2016 Joseph A. Prochazka #
2015-11-04 04:48:08 +00:00
# #
# 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. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
2016-12-21 11:10:17 +00:00
### VARIABLES
2015-12-17 04:38:06 +00:00
PROJECT_ROOT_DIRECTORY="$PWD"
BASH_DIRECTORY="$PROJECT_ROOT_DIRECTORY/bash"
LOG_DIRECTORY="$PROJECT_ROOT_DIRECTORY/logs"
2015-11-04 04:48:08 +00:00
### INCLUDE EXTERNAL SCRIPTS
2016-12-20 21:39:09 +00:00
source $BASH_DIRECTORY/functions.sh
2016-12-20 21:39:09 +00:00
2016-12-21 11:10:17 +00:00
### USAGE
usage()
{
echo -e ""
echo -e "Usage: $0 [OPTIONS] [ARGUMENTS]"
echo -e ""
echo -e "Option GNU long option Meaning"
echo -e "-c <FILE> --config-file <FILE> The configuration file to be use for an unattended installation."
echo -e "-h --help Shows this message."
echo -e "-l --log-output Logs all output to a file in the logs directory."
echo -e "-u --unattended Begins an unattended installation using a configuration file."
echo -e "-v --verbose Provides extra confirmation at each stage of the install."
echo -e ""
}
2016-12-21 11:10:17 +00:00
### CHECK FOR OPTIONS AND ARGUMENTS
2016-12-08 22:10:13 +00:00
while [[ $# -gt 0 ]]; do
2016-12-08 22:10:13 +00:00
case "$1" in
-h|--help)
# Display a help message.
usage
2016-12-08 22:10:13 +00:00
exit 0
;;
-c|--config-file)
2016-12-21 11:10:17 +00:00
# The specified installation configuration file.
export ADSB_CONFIGURATION_FILE="$2"
2016-12-21 11:10:17 +00:00
shift 2
;;
2016-12-08 22:10:13 +00:00
-l|--log-output)
# Enable logging to a file in the logs directory.
2016-12-08 22:10:13 +00:00
ENABLE_LOGGING="true"
shift 1
2016-12-08 22:10:13 +00:00
;;
2016-12-20 22:01:26 +00:00
-u|--unattended)
# Enable logging to a log file.
export GLOBAL_UNATTENDED_INSTALL="true"
2016-12-21 11:10:17 +00:00
shift 1
;;
-v|--verbose)
# Provides extra confirmation at each stage of the install.
2016-12-21 11:10:17 +00:00
export VERBOSE="true"
shift 1
;;
2016-12-08 22:10:13 +00:00
*)
# Unknown options were set so exit.
echo -e "Error: Unknown option: $1" >&2
usage
exit 1
2016-12-08 22:10:13 +00:00
;;
esac
done
2016-12-21 11:10:17 +00:00
### UNATTENDED INSTALL
if [[ $GLOBAL_UNATTENDED_INSTALL = "true" ]] ; then
2016-12-21 11:10:17 +00:00
echo "The unattended installation option is still in development..."
exit 1
fi
### EXECUTE BASH/INIT.SH
2016-09-23 21:10:29 +00:00
chmod +x $BASH_DIRECTORY/init.sh
2016-12-21 11:10:17 +00:00
if [[ ! -z $ENABLE_LOGGING ]] && [[ $ENABLE_LOGGING = "true" ]] ; then
2016-12-08 22:10:13 +00:00
# Execute init.sh logging all output to the log drectory as the file name specified.
LOG_FILE="$LOG_DIRECTORY/install_$(date +"%m_%d_%Y_%H_%M_%S").log"
$BASH_DIRECTORY/init.sh 2>&1 | tee -a "$LOG_FILE"
CleanLogFile "$LOG_FILE"
2016-12-08 22:10:13 +00:00
else
# Execute init.sh without logging any output to the log directory.
$BASH_DIRECTORY/init.sh
2016-09-23 21:10:29 +00:00
fi
2016-12-21 11:10:17 +00:00
### CLEAN UP
# Remove any global variables assigned by this script.
unset GLOBAL_UNATTENDED_INSTALL
unset ADSB_CONFIGURATION_FILE
2016-12-21 11:10:17 +00:00
unset VERBOSE
2015-11-04 04:48:08 +00:00
2016-12-21 11:10:17 +00:00
# Check if any errors were encountered by any child scripts.
# If no errors were encountered then exit this script cleanly.
if [[ $? -ne 0 ]] ; then
exit 1
2016-12-21 11:10:17 +00:00
else
exit 0
fi