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 9505cd9..5c7dca0 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 + ### USAGE usage() @@ -47,12 +51,12 @@ usage() echo -e "" echo -e "Usage: $0 [OPTIONS] [ARGUMENTS]" echo -e "" - echo -e "Option GNU long option Meaning" - echo -e "-c --config-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 "Option GNU long option Meaning" + echo -e "-c --config-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 "" } @@ -65,15 +69,20 @@ while [[ $# -gt 0 ]]; do usage exit 0 ;; - -c|--config-file*) + -c|--config-file) # The specified installation configuration file. - export ADSB_CONFIGURATIONFILE=$2 + export ADSB_CONFIGURATIONFILE="$2" shift 2 ;; -l|--log-output) # Enable logging to a file in the logs directory. ENABLE_LOGGING="true" - shift + shift 1 + ;; + -u|--unattended) + # Enable logging to a log file. + export AUTOMATED_INSTALLATION_ENABLED="true" + shift 1 ;; -u|--unattended) # Enable logging to a log file. @@ -83,7 +92,7 @@ while [[ $# -gt 0 ]]; do -v|--verbose) # Provides extra confirmation at each stage of the install. export VERBOSE="true" - shift + shift 1 ;; *) # Unknown options were set so exit. @@ -95,6 +104,7 @@ while [[ $# -gt 0 ]]; do done ### UNATTENDED INSTALL + if [[ $AUTOMATED_INSTALLATION_ENABLED = "true" ]] ; then echo "The unattended installation option is still in development..." exit 1 @@ -105,7 +115,9 @@ fi 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" + 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 @@ -118,6 +130,13 @@ unset AUTOMATED_INSTALLATION_ENABLED unset ADSB_CONFIGURATIONFILE unset VERBOSE +### TIDY UP + +# Remove any global variables assigned by this script. +unset AUTOMATED_INSTALLATION_ENABLED +unset ADSB_CONFIGURATIONFILE +unset VERBOSE + # Check if any errors were encountered by any child scripts. # If no errors were encountered then exit this script cleanly. if [[ $? -ne 0 ]] ; then