From e88b12e6a6bcae672adb3ac54cd482c73e388608 Mon Sep 17 00:00:00 2001 From: Joe Prochazka Date: Tue, 20 Dec 2016 16:39:09 -0500 Subject: [PATCH 1/2] Added logging to installer. --- bash/functions.sh | 11 +++++++++++ bash/variables.sh | 2 +- install.sh | 12 +++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/bash/functions.sh b/bash/functions.sh index bfb206e..dc87c96 100755 --- a/bash/functions.sh +++ b/bash/functions.sh @@ -106,3 +106,14 @@ function UncommentConfig { # Use sed to locate the "KEY" then uncomment the line containing it in the specified "FILE". sudo sed -i -e "/$1/s/^#//" $2 } + +# The following function is used to clean up the log files by removing +# any color escaping sequences from the log file so it is easier to read. +# There are other lines not needed which can be removed as well. + +function CleanLogFile { + # Use sed to remove any color sequences from the specified "FILE". + sed -i "s,\x1B\[[0-9;]*[a-zA-Z],,g" $1 + # Remove the "Press enter to continue..." lines from the log file. + sed -i "/Press enter to continue.../d" $1 +} diff --git a/bash/variables.sh b/bash/variables.sh index 475bd2d..e1d8125 100644 --- a/bash/variables.sh +++ b/bash/variables.sh @@ -34,7 +34,7 @@ ## SOFTWARE VERSIONS # The ADS-B Receiver Project -PROJECTVERSION="2.5.0" +PROJECTVERSION="2.6.0" # FlightAware PiAware PIAWAREVERSION="3.1.0" diff --git a/install.sh b/install.sh index 6701dde..f6c4a43 100755 --- a/install.sh +++ b/install.sh @@ -40,6 +40,10 @@ PROJECTROOTDIRECTORY="$PWD" BASHDIRECTORY="$PROJECTROOTDIRECTORY/bash" LOGDIRECTORY="$PROJECTROOTDIRECTORY/logs" +## INCLUDE EXTERNAL SCRIPTS + +source $BASHDIRECTORY/functions.sh + ## CHECK FOR OPTIONS AND ARGUMENTS while test $# -gt 0; do @@ -55,7 +59,7 @@ while test $# -gt 0; do ;; -l|--log-output) # Enable logging to a log file. - ENABLE_LOGGING="true" + ENABLELOGGING="true" shift ;; *) @@ -66,9 +70,11 @@ while test $# -gt 0; do done chmod +x $BASHDIRECTORY/init.sh -if [ ! -z $ENABLE_LOGGING ] && [ $ENABLE_LOGGING = "true" ]; then +if [ ! -z $ENABLELOGGING ] && [ $ENABLELOGGING = "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" + LOGFILE="$LOGDIRECTORY/install_$(date +"%m_%d_%Y_%H_%M_%S").log" + $BASHDIRECTORY/init.sh 2>&1 | tee -a "$LOGFILE" + CleanLogFile "$LOGFILE" else # Execute init.sh without logging any output to the log directory. $BASHDIRECTORY/init.sh From 31e8c287a5acbbd5c5a109c58af831c5651c02fd Mon Sep 17 00:00:00 2001 From: Joe Prochazka Date: Tue, 20 Dec 2016 17:01:26 -0500 Subject: [PATCH 2/2] Added switchs for unattended installs. --- install.sh | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index f6c4a43..b2402b6 100755 --- a/install.sh +++ b/install.sh @@ -52,9 +52,11 @@ while test $# -gt 0; do # 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." + 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." + echo "-u --unattended Begins an unattended installation using a configuration file." + echo "-c --config-file= The configuration file to be use for an unattended installation." exit 0 ;; -l|--log-output) @@ -62,6 +64,16 @@ while test $# -gt 0; do ENABLELOGGING="true" shift ;; + -u|--unattended) + # Enable logging to a log file. + export ADSB_UNATTENDED="true" + shift + ;; + -c|--config-file*) + # The specified installation configuration file. + export ADSB_CONFIGURATIONFILE=`echo $1 | sed -e 's/^[^=]*=//g'` + shift + ;; *) # No options were set so exit. break @@ -69,6 +81,11 @@ while test $# -gt 0; do esac done +if [ $ADSB_UNATTENDED = "true" ]; then + echo "The unattended installation option is still in development..." + exit 1 +fi + chmod +x $BASHDIRECTORY/init.sh if [ ! -z $ENABLELOGGING ] && [ $ENABLELOGGING = "true" ]; then # Execute init.sh logging all output to the log drectory as the file name specified. @@ -79,6 +96,15 @@ else # Execute init.sh without logging any output to the log directory. $BASHDIRECTORY/init.sh fi + +# Remove any global variables assigned by this script. +unset ADSB_UNATTENDED +unset ADSB_CONFIGURATIONFILE + +# 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 +else + exit 0 fi