style: rename functions to clear spellcheck

This commit is contained in:
Asif Bacchus 2021-05-09 08:45:24 -06:00
parent 39f5445c28
commit 3f9d164285

104
cfddns.sh
View File

@ -109,25 +109,25 @@ scriptExamples() {
newline newline
printf "Update Cloudflare DNS host A/AAAA records with current IP address.\n" printf "Update Cloudflare DNS host A/AAAA records with current IP address.\n"
printf "%sUsage: %s --records host.domain.tld[,host2.domain.tld,...] [parameters]%s\n\n" "$bold" "$scriptName" "$norm" printf "%sUsage: %s --records host.domain.tld[,host2.domain.tld,...] [parameters]%s\n\n" "$bold" "$scriptName" "$norm"
textblock "${magenta}--- usage examples ---${norm}" textBlock "${magenta}--- usage examples ---${norm}"
newline newline
textblockSwitches "${scriptName} -r myserver.mydomain.net" textBlockSwitches "${scriptName} -r myserver.mydomain.net"
textblock "Update Cloudflare DNS records for myserver.mydomain.net with the auto-detected public IP4 address. Credentials will be expected in the default location and the log will be written in the default location also." textBlock "Update Cloudflare DNS records for myserver.mydomain.net with the auto-detected public IP4 address. Credentials will be expected in the default location and the log will be written in the default location also."
newline newline
textblockSwitches "${scriptName} -r myserver.mydomain.net -6" textBlockSwitches "${scriptName} -r myserver.mydomain.net -6"
textblock "Same as above, but update AAAA host records with the auto-detected public IP6 address." textBlock "Same as above, but update AAAA host records with the auto-detected public IP6 address."
newline newline
textblockSwitches "${scriptName} -r myserver.mydomain.net,otherserver.mydomain.net -l /var/log/cfddns.log --nc" textBlockSwitches "${scriptName} -r myserver.mydomain.net,myserver2.mydomain.net -l /var/log/cfddns.log --nc"
textblock "Update DNS entries for both listed hosts using auto-detected IP4 address. Write a non-coloured log to '/var/log/cfddns.log'." textBlock "Update DNS entries for both listed hosts using auto-detected IP4 address. Write a non-coloured log to '/var/log/cfddns.log'."
newline newline
textblockSwitches "${scriptName} -r myserver.mydomain.net,otherserver.mydomain.net -l /var/log/cfddns.log --ip6 --ip fd21:7a62:2737:9c3a::a151" textBlockSwitches "${scriptName} -r myserver.mydomain.net,myserver2.mydomain.net -l /var/log/cfddns.log --ip6 --ip fd21:7a62:2737:9c3a::a151"
textblock "Update DNS AAAA entries for listed hosts using the *specified* IP address. Write a colourful log to the location specified." textBlock "Update DNS AAAA entries for listed hosts using the *specified* IP address. Write a colourful log to the location specified."
newline newline
textblockSwitches "${scriptName} -r myserver.mydomain.net -c /root/cloudflare.creds -l /var/log/cfddns.log --ip 1.2.3.4" textBlockSwitches "${scriptName} -r myserver.mydomain.net -c /root/cloudflare.creds -l /var/log/cfddns.log --ip 1.2.3.4"
textblock "Update DNS A entry for listed hostname with the provided IP address. Read cloudflare credentials file from specified location, save log in specified location." textBlock "Update DNS A entry for listed hostname with the provided IP address. Read cloudflare credentials file from specified location, save log in specified location."
newline newline
textblockSwitches "${scriptName} -r myserver.mydomain.net -c /root/cloudflare.creds -l /var/log/cfddns.log -6 -i fd21:7a62:2737:9c3a::a151" textBlockSwitches "${scriptName} -r myserver.mydomain.net -c /root/cloudflare.creds -l /var/log/cfddns.log -6 -i fd21:7a62:2737:9c3a::a151"
textblock "Exact same as above, but change the AAAA record. This is how you run the script once for IP4 and again for IP6." textBlock "Exact same as above, but change the AAAA record. This is how you run the script once for IP4 and again for IP6."
exit 0 exit 0
} }
@ -135,54 +135,54 @@ scriptHelp() {
newline newline
printf "Update Cloudflare DNS host A/AAAA records with current IP address.\n" printf "Update Cloudflare DNS host A/AAAA records with current IP address.\n"
printf "%sUsage: %s --records host.domain.tld[,host2.domain.tld,...] [parameters]%s\n\n" "$bold" "$scriptName" "$norm" printf "%sUsage: %s --records host.domain.tld[,host2.domain.tld,...] [parameters]%s\n\n" "$bold" "$scriptName" "$norm"
textblock "The only required parameter is '--records' which is a comma-delimited list of hostnames to update. However, there are several other options which may be useful to implement." textBlock "The only required parameter is '--records' which is a comma-delimited list of hostnames to update. However, there are several other options which may be useful to implement."
textblock "Parameters are listed below and followed by a description of their effect. If a default value exists, it will be listed on the following line in (parentheses)." textBlock "Parameters are listed below and followed by a description of their effect. If a default value exists, it will be listed on the following line in (parentheses)."
newline newline
textblock "${magenta}--- script related parameters ---${norm}" textBlock "${magenta}--- script related parameters ---${norm}"
newline newline
textblockSwitches "-c | --cred | --creds | --credentials | -f (deprecated, backward-compatibility)" textBlockSwitches "-c | --cred | --creds | --credentials | -f (deprecated, backward-compatibility)"
textblock "Path to file containing your Cloudflare *token* credentials. Please refer to the repo README for more information on format, etc." textBlock "Path to file containing your Cloudflare *token* credentials. Please refer to the repo README for more information on format, etc."
textblockDefaults "(${accountFile})" textBlockDefaults "(${accountFile})"
newline newline
textblockSwitches "-l | --log" textBlockSwitches "-l | --log"
textblock "Path where the log file should be written." textBlock "Path where the log file should be written."
textblockDefaults "(${logFile})" textBlockDefaults "(${logFile})"
newline newline
textblockSwitches "--nc | --no-color | --no-colour" textBlockSwitches "--nc | --no-color | --no-colour"
textblock "Switch value. Disables ANSI colours in the log. Useful if you review the logs using a reader that does not parse ANSI colour codes." textBlock "Switch value. Disables ANSI colours in the log. Useful if you review the logs using a reader that does not parse ANSI colour codes."
textblockDefaults "(disabled: print logs in colour)" textBlockDefaults "(disabled: print logs in colour)"
newline newline
textblockSwitches "--log-console" textBlockSwitches "--log-console"
textblock "Switch value. Output log to console (stdout) instead of a log file. Can be combined with --nc if desired." textBlock "Switch value. Output log to console (stdout) instead of a log file. Can be combined with --nc if desired."
textblockDefaults "(disabled: output to log file)" textBlockDefaults "(disabled: output to log file)"
newline newline
textblockSwitches "--no-log" textBlockSwitches "--no-log"
textblock "Switch value. Do not create a log (i.e. no console, no file). You will not have *any* output from the script if you choose this option, so you will not know if updates succeeded or failed." textBlock "Switch value. Do not create a log (i.e. no console, no file). You will not have *any* output from the script if you choose this option, so you will not know if updates succeeded or failed."
textblockDefaults "(disabled: output to log file)" textBlockDefaults "(disabled: output to log file)"
newline newline
textblockSwitches "-h | --help | -?" textBlockSwitches "-h | --help | -?"
textblock "Display this help screen." textBlock "Display this help screen."
newline newline
textblockSwitches "--examples" textBlockSwitches "--examples"
textblock "Show some usage examples." textBlock "Show some usage examples."
newline newline
textblock "${magenta}--- DNS related parameters ---${norm}" textBlock "${magenta}--- DNS related parameters ---${norm}"
newline newline
textblockSwitches "-r | --record | --records" textBlockSwitches "-r | --record | --records"
textblock "Comma-delimited list of hostnames for which IP addresses should be updated in Cloudflare DNS. This parameter is REQUIRED. Note that this script will only *update* records, it will not create new ones. If you supply hostnames that are not already defined in DNS, the script will log a warning and will skip those hostnames." textBlock "Comma-delimited list of hostnames for which IP addresses should be updated in Cloudflare DNS. This parameter is REQUIRED. Note that this script will only *update* records, it will not create new ones. If you supply hostnames that are not already defined in DNS, the script will log a warning and will skip those hostnames."
newline newline
textblockSwitches "-i | --ip | --ip-address | -a | --address" textBlockSwitches "-i | --ip | --ip-address | -a | --address"
textblock "New IP address for DNS host records. If you omit this, the script will attempt to auto-detect your public IP address and use that." textBlock "New IP address for DNS host records. If you omit this, the script will attempt to auto-detect your public IP address and use that."
newline newline
textblockSwitches "-4 | --ip4 | --ipv4" textBlockSwitches "-4 | --ip4 | --ipv4"
textblock "Switch value. Update Host 'A' records (IP4) only. Note that this script can only update either A *or* AAAA records. If you need to update both, you'll have to run the script once in IP4 mode and again in IP6 mode. If you specify both this switch and the IP6 switch, the last one specified will take effect." textBlock "Switch value. Update Host 'A' records (IP4) only. Note that this script can only update either A *or* AAAA records. If you need to update both, you'll have to run the script once in IP4 mode and again in IP6 mode. If you specify both this switch and the IP6 switch, the last one specified will take effect."
textblockDefaults "(enabled: update A records)" textBlockDefaults "(enabled: update A records)"
newline newline
textblockSwitches "-6 | --ip6 | --ipv6" textBlockSwitches "-6 | --ip6 | --ipv6"
textblock "Switch value. Update Host 'AAAA' records (IP6) only. Note that this script can only update either A *or* AAAA records. If you need to update both, you'll have to run the script once in IP4 mode and again in IP6 mode. If you specify both this switch and the IP4 switch, the last one specified will take effect." textBlock "Switch value. Update Host 'AAAA' records (IP6) only. Note that this script can only update either A *or* AAAA records. If you need to update both, you'll have to run the script once in IP4 mode and again in IP6 mode. If you specify both this switch and the IP4 switch, the last one specified will take effect."
textblockDefaults "(disabled: update A records)" textBlockDefaults "(disabled: update A records)"
newline newline
textblock "Please refer to the repo README for more detailed information regarding this script and how to automate and monitor it." textBlock "Please refer to the repo README for more detailed information regarding this script and how to automate and monitor it."
newline newline
exit 0 exit 0
} }
@ -195,15 +195,15 @@ newline() {
printf "\n" printf "\n"
} }
textblock() { textBlock() {
printf "%s\n" "$1" | fold -w "$width" -s printf "%s\n" "$1" | fold -w "$width" -s
} }
textblockDefaults() { textBlockDefaults() {
printf "%s%s%s\n" "$yellow" "$1" "$norm" printf "%s%s%s\n" "$yellow" "$1" "$norm"
} }
textblockSwitches() { textBlockSwitches() {
printf "%s%s%s\n" "$cyan" "$1" "$norm" printf "%s%s%s\n" "$cyan" "$1" "$norm"
} }
@ -353,13 +353,13 @@ if [ -z "$ipAddress" ]; then
# detect public ip address # detect public ip address
if [ "$ip4" -eq 1 ]; then if [ "$ip4" -eq 1 ]; then
if ! ipAddress="$(curl -s $ip4DetectionSvc)"; then if ! ipAddress="$(curl -s $ip4DetectionSvc)"; then
printf "ddns ip address: %serror%s\n" "$err" "$norm" >>"$logFile" printf "ddns ip address:%s error%s\n" "$err" "$norm" >>"$logFile"
exitError 10 exitError 10
fi fi
fi fi
if [ "$ip6" -eq 1 ]; then if [ "$ip6" -eq 1 ]; then
if ! ipAddress="$(curl -s $ip6DetectionSvc)"; then if ! ipAddress="$(curl -s $ip6DetectionSvc)"; then
printf "ddns ip address: %serror%s\n" "$err" "$norm" >>"$logFile" printf "ddns ip address:%s error%s\n" "$err" "$norm" >>"$logFile"
exitError 10 exitError 10
fi fi
fi fi