make path to resolv.conf configurable (#1086425)
also modernize the new need_hostname() & change_resolv_conf()
This commit is contained in:
parent
27892ea741
commit
4f66445eba
@ -39,6 +39,8 @@ LOGLEVEL="notice"
|
|||||||
|
|
||||||
ETCDIR="/etc/dhcp"
|
ETCDIR="/etc/dhcp"
|
||||||
|
|
||||||
|
RESOLVCONF="/etc/resolv.conf"
|
||||||
|
|
||||||
logmessage() {
|
logmessage() {
|
||||||
msg="${1}"
|
msg="${1}"
|
||||||
logger -p "${LOGFACILITY}.${LOGLEVEL}" -t "NET" "dhclient: ${msg}"
|
logger -p "${LOGFACILITY}.${LOGLEVEL}" -t "NET" "dhclient: ${msg}"
|
||||||
@ -84,7 +86,7 @@ eventually_add_hostnames_domain_to_search() {
|
|||||||
|
|
||||||
if [ "${is_in}" = "false" ]; then
|
if [ "${is_in}" = "false" ]; then
|
||||||
# Add domain name to search list (#637763)
|
# Add domain name to search list (#637763)
|
||||||
sed -i -e "s/${search}/${search} ${domain}/" /etc/resolv.conf
|
sed -i -e "s/${search}/${search} ${domain}/" "${RESOLVCONF}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -659,31 +661,32 @@ dh6config() {
|
|||||||
need_hostname ()
|
need_hostname ()
|
||||||
{
|
{
|
||||||
CHECK_HOSTNAME=$(hostname)
|
CHECK_HOSTNAME=$(hostname)
|
||||||
if [ "$CHECK_HOSTNAME" = "(none)" -o "$CHECK_HOSTNAME" = "localhost" -o \
|
if [[ "${CHECK_HOSTNAME}" = "(none)" ]] ||
|
||||||
"$CHECK_HOSTNAME" = "localhost.localdomain" ]; then
|
[[ "${CHECK_HOSTNAME}" = "localhost" ]] ||
|
||||||
return 0
|
[[ "${CHECK_HOSTNAME}" = "localhost.localdomain" ]]; then
|
||||||
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Takes one argument - temporary resolv.conf file
|
||||||
change_resolv_conf ()
|
change_resolv_conf ()
|
||||||
{
|
{
|
||||||
s=$(grep '^[\ \ ]*option' /etc/resolv.conf 2>/dev/null);
|
options=$(grep '^[\ \ ]*option' "${RESOLVCONF}" 2>/dev/null);
|
||||||
if [ $# -eq 1 ]; then
|
if [[ -n "${options}" ]]; then
|
||||||
if [ "x$s" != "x" ]; then
|
# merge options from existing resolv.conf with specified resolv.conf content
|
||||||
s="$s"$'\n'$(grep -vF "$s" $1);
|
newres="${options}"$'\n'$(grep -vF "${options}" "${1}");
|
||||||
else
|
else
|
||||||
s=$(cat $1);
|
newres=$(cat "${1}");
|
||||||
fi;
|
|
||||||
fi;
|
fi;
|
||||||
(echo "$s" > /etc/resolv.conf;) >/dev/null 2>&1;
|
|
||||||
r=$?;
|
eval $(echo "${newres}" > "${RESOLVCONF}"; echo "status=$?")
|
||||||
if [ $r -eq 0 ]; then
|
if [[ $status -eq 0 ]]; then
|
||||||
logger -p local7.notice -t "NET" -i "$0 : updated /etc/resolv.conf";
|
logger -p local7.notice -t "NET" -i "${0} : updated ${RESOLVCONF}";
|
||||||
[ -e /var/run/nscd/socket ] && /usr/sbin/nscd -i hosts; # invalidate cache
|
[[ -e /var/run/nscd/socket ]] && /usr/sbin/nscd -i hosts; # invalidate cache
|
||||||
fi;
|
fi;
|
||||||
return $r;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
need_config ()
|
need_config ()
|
||||||
|
@ -677,6 +677,7 @@ done
|
|||||||
%changelog
|
%changelog
|
||||||
* Tue Jul 14 2015 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.2-11
|
* Tue Jul 14 2015 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.2-11
|
||||||
- remove dependency on initscripts (#1098172)
|
- remove dependency on initscripts (#1098172)
|
||||||
|
- make path to resolv.conf configurable (#1086425)
|
||||||
|
|
||||||
* Thu Jul 09 2015 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.2-10
|
* Thu Jul 09 2015 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.2-10
|
||||||
- spec cleanup
|
- spec cleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user