From e24f578b8f608727b8ec39b0a5ca133f1f4249e4 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 13 Sep 2018 21:15:31 -0600 Subject: [PATCH] Added log verbosity options --- cfddns.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/cfddns.sh b/cfddns.sh index 0f57fcd..840ec61 100755 --- a/cfddns.sh +++ b/cfddns.sh @@ -132,36 +132,61 @@ errorExplain[201]="Could not detect this machine's IP address. Please re-run thi errorExplain[254]="Could not connect with CloudFlare API. Please re-run this script later." +## Logging parameters -- default set to 'quiet' in same directory as this script +scriptPath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +logFile="$scriptPath/cfddns.log" +logQuietFile="$logFile" +unset logVerboseFile + + ### Process script parameters if [ -z $1 ]; then scriptHelp 1 fi -while getopts ':f:r:i:46hx' PARAMS; do +while getopts ':f:r:i:46hxlvq' PARAMS; do case "$PARAMS" in f) + # path to file with CloudFlare account details accountFile="${OPTARG}" ;; r) + # DNS records to update dnsRecords+=($OPTARG) ;; i) + # IP address to use -- NOT parsed for correctness ipAddress="$OPTARG" ;; 4) + # Put script in IP4 mode (default) ip4=1 ip6=0 ;; 6) + # Put script in IP6 mode ip4=0 ip6=1 ;; h) + # Display info on script usage scriptHelp ;; x) + # Show examples of script usage scriptExamples ;; + l) + # Path to write log file + logFile="${OPTARG}" + v) + # Verbose logging mode + logVerboseFile="$logFile" + unset logQuietFile + q) + # Quiet logging mode (default) + logQuietFile="$logFile" + unset logVerboseFile ?) scriptHelp 1 ;;