X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02.git/blobdiff_plain/6a2cd888e8ae624ddd3e885f4de2b40581adf387..c9c573da200aef5273d6d55ef03bb6da7e0eb150:/exec/bkgpslog diff --git a/exec/bkgpslog b/exec/bkgpslog index f48818d..3a7bae8 100755 --- a/exec/bkgpslog +++ b/exec/bkgpslog @@ -213,7 +213,7 @@ processArguments() { -r | --recipient) OPTION_RECIPIENTS="true"; argRecPubKeys+=("$2"); vbm "STATUS:pubkey added:""$2"; shift;; # Add recipients -c | --compress) OPTION_COMPRESS="true"; vbm "DEBUG:Compressed output mode enabled.";; # Enable compression -z | --time-zone) try setTimeZoneEV "$2"; shift;; # Set timestamp timezone - -t | --temp-dir) OPTION_TMPDIR="true" && argTmpDirPriority="$2"; shift;; # Set time zone + -t | --temp-dir) OPTION_TMPDIR="true" && argTempDirPriority="$2"; shift;; # Set time zone -R | --recipient-dir) OPTION_RECIPIENTS="true"; OPTION_RECDIR="true" && argRecDir="$2"; shift;; # Add recipient watch dir *) echoerr "ERROR: Unrecognized argument: $1"; echoerr "STATUS:All arguments:$*"; exit 1;; # Handle unrecognized options. esac @@ -952,14 +952,15 @@ magicGatherWriteBuffer() { } # write buffer to disk magicParseRecipientDir() { # Desc: Updates recPubKeysValid with pubkeys in dir specified by '-R' option ("recipient directory") - # Inputs: vars: OPTION_RECDIR, argRecDir, - # arry: recPubKeysValid - # Outputs: arry: recPubKeysValid (modified with pubkeys in argRecDir if pubkeys valid) + # Inputs: vars: OPTION_RECDIR, argRecDir, OPTION_ENCRYPTION + # arry: recPubKeysValid + # Outputs: arry: recPubKeysValid # Depends: processArguments, local recFileLine updateRecipients recipientDir declare -a candRecPubKeysValid - - if [[ "$OPTION_RECDIR" = "true" ]]; then + + # Check that '-e' and '-R' set + if [[ "$OPTION_ENCRYPTION" = "true" ]] && [[ "$OPTION_RECDIR" = "true" ]]; then ### Check that argRecDir is a directory. if [[ -d "$argRecDir" ]]; then recipientDir="$argRecDir"; @@ -990,6 +991,12 @@ magicParseRecipientDir() { yell "ERROR:$0:Recipient directory $argRecDir does not exist. Exiting."; exit 1; fi; fi; + # Handle case if '-e' set but '-R' not set + if [[ "$OPTION_ENCRYPTION" = "true" ]] && [[ ! "$OPTION_RECDIR" = "true" ]]; then + yell "ERROR: \'-e\' set but \'-R\' is not set."; fi; + # Handle case if '-R' set but '-e' not set + if [[ ! "$OPTION_ENCRYPTION" = "true" ]] && [[ "$OPTION_RECDIR" = "true" ]]; then + yell "ERROR: \'-R\' is set but \'-e\' is not set."; fi; } # Update recPubKeysValid with argRecDir magicParseRecipientArgs() { # Desc: Parses recipient arguments specified by '-r' option @@ -1057,7 +1064,8 @@ magicParseCompressionArg() { } # Form compression cmd string and filename suffix magicInitWorkingDir() { # Desc: Determine temporary working directory from defaults or user input - # Input: vars: OPTION_TEMPDIR, argTmpDirPriority, DIR_TMP_DEFAULT + # Usage: magicInitWorkignDir + # Input: vars: OPTION_TEMPDIR, argTempDirPriority, DIR_TMP_DEFAULT # Input: vars: SCRIPT_TIME_START # Output: vars: DIR_TMP # Depends: processArguments(), vbm(), yell() @@ -1069,7 +1077,7 @@ magicInitWorkingDir() { if [[ -d "$argTempDirPriority" ]]; then DIR_TMP_PARENT="$argTempDirPriority"; else - yell "WARNING:Specified temporary working directory not valid:$OPTION_TMPDIR"; + yell "WARNING:Specified temporary working directory not valid:$argTempDirPriority"; exit 1; # Exit since user requires a specific temp dir and it is not available. fi; else @@ -1093,14 +1101,14 @@ main() { processArguments "$@"; ## Act upon arguments ### Determine working directory - magicInitWorkingDir; + magicInitWorkingDir; # Sets DIR_TMP from argTempDirPriority ### Set output encryption and compression option strings #### React to "-r" ("encryption recipients") option - magicParseRecipientArgs; + magicParseRecipientArgs; # Updates recPubKeysValid, CMD_ENCRYPT[_SUFFIX] #### React to "-c" ("compression") option - magicParseCompressionArg; + magicParseCompressionArg; # Updates CMD_COMPRESS[_SUFFIX] #### React to "-R" ("recipient directory") option - magicParseRecipientDir; + magicParseRecipientDir; # Updates recPubKeysValid # Check that critical apps and dirs are available, display missing ones. if ! checkapp gpspipe tar && ! checkdir "$DIR_OUT" "DIR_TMP"; then