Remove DEBUG messages for MyFqdn

Cause the function is used to define the path of a file.
This commit is contained in:
Jeremy Gardais 2018-04-26 15:19:10 +02:00
parent e0e5915fde
commit f5ef9d67b1
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 2 additions and 3 deletions

View File

@ -76,10 +76,10 @@ function GetMyHostKey() {
## IpAddress {{{
function IpAddress() {
# Don't add DEBUG messages cause this function is called to define the path of a file
local strMyIpAddress
strMyIpAddress=''
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
printf '\e[1;31m%-6s\e[m\n' "ERREUR: Impossible de récupérer l'adresse IP de cette machine (${strMyIpAddress})."
return 1
@ -90,12 +90,11 @@ function IpAddress() {
## MyFqdn {{{
function MyFqdn() {
# Don't add DEBUG messages cause this function is called to define the path of a file
local strMyIpAddress
local strMyFqdn
strMyIpAddress=$( IpAddress ) # eg '129.20.27.49'
[[ "${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 '.'
}
## }}}