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
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
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
fi
echo "{$strMyIpAddress}"
@ -92,7 +93,9 @@ function MyFqdn() {
local strMyIpAddress
local strMyFqdn
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 '.'
}
## }}}
@ -182,11 +185,11 @@ function AllowBackuppcSudo() {
# Ensure to create the sudoers directory
sudo mkdir -p -- "${sudoersDir}"
[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG: Création du dossier pour les sudoers (${sudoersDir})."
[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG: Création du dossier pour les sudoers (${sudoersDir})."
# Allow backuppc user to use rsync with sudo
sudo sh -c "echo '${userLogin} ALL=(ALL:ALL) NOEXEC:NOPASSWD: /usr/bin/rsync' > ${sudoersDir}/backuppc_noexec"
[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG: Ajout des autorisations sudo pour l'utilisateur (${userLogin}) dans le fichier (${sudoersDir}/backuppc_noexec)."
[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG: Ajout des autorisations sudo pour l'utilisateur (${userLogin}) dans le fichier (${sudoersDir}/backuppc_noexec)."
}
## }}}
# }}}