On 04/21/16 at 03:44pm, Xunlei Pang wrote:
There are two issues by doing this:
1) The dns sequence is different from that in 1st system.
2) There are some duplicated items.
NOTE: kdump_setup_dns() meant to avoid the duplication,
but the original shell command is actually disfunctional:
"[ ! $(cat $_dnsfile | grep -q $_dns) ]" (always true)
Hi.
This test is useful in previous context, since there may be duplicate
DNS entries in /etc/resolv.conf. It is safe to remove it in your patch,
because the deplicate DNS entries will be remove later.
Thanks
Minfei
>
> Fix the issues by firstly parsing "/etc/resolv.conf", then
> parsing ifcfg file, finally delete the duplicated items.
>
> Signed-off-by: Xunlei Pang <xlpang(a)redhat.com>
> ---
> dracut-module-setup.sh | 27 ++++++++++++++++-----------
> 1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> index 350864e..b7763f7 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -68,14 +68,6 @@ kdump_setup_dns() {
> local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
> local ifcfg_file
>
> - ifcfg_file=$(get_ifcfg_filename $1)
> - if [ -f "${ifcfg_file}" ]; then
> - . ${ifcfg_file}
> - fi
> -
> - [ -n "$DNS1" ] && echo "nameserver=$DNS1" >
"$_dnsfile"
> - [ -n "$DNS2" ] && echo "nameserver=$DNS2" >>
"$_dnsfile"
> -
> while read content;
> do
> _nameserver=$(echo $content | grep ^nameserver)
> @@ -84,10 +76,23 @@ kdump_setup_dns() {
> _dns=$(echo $_nameserver | cut -d' ' -f2)
> [ -z "$_dns" ] && continue
>
> - if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then
> - echo "nameserver=$_dns" >> "$_dnsfile"
> - fi
> + echo "nameserver=$_dns" >> "$_dnsfile"
> done < "/etc/resolv.conf"
> +
> + unset DNS1 DNS2
> + ifcfg_file=$(get_ifcfg_filename $1)
> + if [ -f "${ifcfg_file}" ]; then
> + . ${ifcfg_file}
> + fi
> +
> + [ -n "$DNS1" ] && echo "nameserver=$DNS1" >>
"$_dnsfile"
> + [ -n "$DNS2" ] && echo "nameserver=$DNS2" >>
"$_dnsfile"
> +
> + # Delete duplicated lines
> + if [ -f "$_dnsfile" ]; then
> + awk '!a[$0]++' $_dnsfile > $_dnsfile.tmp
> + mv -f $_dnsfile.tmp $_dnsfile
> + fi
> }
>
> #$1: netdev name
> --
> 1.8.3.1
> _______________________________________________
> kexec mailing list
> kexec(a)lists.fedoraproject.org
>
http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org