Add DEBUG messages for MyFqdn function

This commit is contained in:
Jeremy Gardais 2018-04-26 15:13:32 +02:00
parent ebf03aaf8e
commit e0e5915fde
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 7 additions and 4 deletions

View File

@ -79,8 +79,9 @@ function IpAddress() {
local strMyIpAddress local strMyIpAddress
strMyIpAddress='' strMyIpAddress=''
strMyIpAddress=$(dig +short myip.opendns.com @resolver1.opendns.com) strMyIpAddress=$(dig +short myip.opendns.com @resolver1.opendns.com)
[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG: Fonction IpAddress - strMyIpAddress = ${strMyIpAddress}."
if [ "${strMyIpAddress}" == '' ]; then if [ "${strMyIpAddress}" == '' ]; then
error "failed to retrieve the ip address of this machine" printf '\e[1;31m%-6s\e[m\n' "ERREUR: Impossible de récupérer l'adresse IP de cette machine (${strMyIpAddress})."
return 1 return 1
fi fi
echo "{$strMyIpAddress}" echo "{$strMyIpAddress}"
@ -92,7 +93,9 @@ function MyFqdn() {
local strMyIpAddress local strMyIpAddress
local strMyFqdn local strMyFqdn
strMyIpAddress=$( IpAddress ) # eg '129.20.27.49' strMyIpAddress=$( IpAddress ) # eg '129.20.27.49'
strMyFqdn=$(host "${strMyIpAddress}" | awk '{print $5}') [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG: Fonction MyFqdn - strMyIpAddress = ${strMyIpAddress}."
strMyFqdn=$(host "$strMyIpAddress" | awk '{print $5}')
[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG: Fonction MyFqdn - strMyFqdn = ${strMyFqdn}."
echo "${strMyFqdn%?}" # remove the trailing '.' echo "${strMyFqdn%?}" # remove the trailing '.'
} }
## }}} ## }}}