mirror of
https://github.com/m8tin/cis.git
synced 2025-12-06 15:58:26 +01:00
much better
This commit is contained in:
@@ -11,18 +11,21 @@ _CORE_SCRIPTS="$(dirname ${_SCRIPT:?"Missing SCRIPT"} 2> /dev/null)/"
|
|||||||
_CIS_ROOT="$(dirname ${_CORE_SCRIPTS:?"Missing CORE_SCRIPTS"} 2> /dev/null)/"
|
_CIS_ROOT="$(dirname ${_CORE_SCRIPTS:?"Missing CORE_SCRIPTS"} 2> /dev/null)/"
|
||||||
_OVERRIDE_DOMAIN_FILE="${_CIS_ROOT:?"Missing CIS_ROOT"}overrideOwnDomain"
|
_OVERRIDE_DOMAIN_FILE="${_CIS_ROOT:?"Missing CIS_ROOT"}overrideOwnDomain"
|
||||||
|
|
||||||
# Wenn OVERRIDING_DOMAIN_FILE enhält lesbare Daten
|
|
||||||
grep '[^[:space:]]' "${_OVERRIDE_DOMAIN_FILE:?"Missing OVERRIDE_DOMAIN_FILE"}" &> /dev/null \
|
|
||||||
&& echo "WARNING: Domain has been overridden by: ${_OVERRIDE_DOMAIN_FILE}" > /dev/stderr \
|
|
||||||
&& cat "${_OVERRIDE_DOMAIN_FILE}" \
|
|
||||||
&& exit 0
|
|
||||||
|
|
||||||
_BOOT_HOSTNAME="$(hostname -b)"
|
|
||||||
# There has to be one dot at least.
|
# There has to be one dot at least.
|
||||||
echo "${_BOOT_HOSTNAME}" | grep -v '\.' &> /dev/null \
|
_BOOT_DOMAIN="$(hostname -b | grep -F '.' | cut -d. -f2-)"
|
||||||
&& echo "It was impossible to find out the domain of this host, please prepare this host first." > /dev/stderr \
|
|
||||||
&& exit 1
|
|
||||||
|
|
||||||
#Removes shortest matching pattern '*.' from the begin to get the domain
|
# Take OVERRIDING_DOMAIN_FILE without empty lines and comments, then take the first line without leading spaces
|
||||||
echo "${_BOOT_HOSTNAME#*.}" \
|
_OVERRIDE_DOMAIN="$(grep -vE '^[[:space:]]*$|^[[:space:]]*#' "${_OVERRIDE_DOMAIN_FILE}" 2> /dev/null | head -n 1 | xargs)"
|
||||||
|
|
||||||
|
! [ -z "${_OVERRIDE_DOMAIN}" ] \
|
||||||
|
&& [ "${_OVERRIDE_DOMAIN}" != "${_BOOT_DOMAIN}" ] \
|
||||||
|
&& echo "WARNING: Domain has been overridden by: ${_OVERRIDE_DOMAIN_FILE}" > /dev/stderr \
|
||||||
|
&& echo "${_OVERRIDE_DOMAIN}" \
|
||||||
&& exit 0
|
&& exit 0
|
||||||
|
|
||||||
|
! [ -z "${_BOOT_DOMAIN}" ] \
|
||||||
|
&& echo "${_BOOT_DOMAIN}" \
|
||||||
|
&& exit 0
|
||||||
|
|
||||||
|
echo "It was impossible to find out the domain of this host, please prepare this host first." > /dev/stderr
|
||||||
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user