Previously, we assumed the ifcfg file of a network "interface" is "/etc/sysconfig/network-scripts/ifcfg-<interface>", but actually it is not the case.
For example, for network interface "enp0s25", we are able to generate like "/etc/sysconfig/network-scripts/ifcfg-enp0s25-test" for it via network-manager.
The "suffix" in "ifcfg-<suffix>" is actually a "configuration" name not "interface" name, though normally we use the "interface" name as its "configuration" name. You can refer to "man ifup" for some detail.
So, this patch adds some assistant helpers to acquire the right ifcfg file for an interface. Borrow some logic from script below: "/etc/sysconfig/network-scripts/network-functions"
Signed-off-by: Xunlei Pang xlpang@redhat.com --- kdump-lib.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 4d34206..90913c5 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -230,3 +230,105 @@ is_hostname() fi echo $1 | grep -q "[a-zA-Z]" } + +get_hwaddr() +{ + if [ -f "/sys/class/net/${1}/address" ]; then + awk '{ print toupper($0) }' < /sys/class/net/${1}/address + elif [ -d "/sys/class/net/${1}" ]; then + ip -o link show ${1} 2>/dev/null | \ + awk '{ print toupper(gensub(/.*link/[^ ]* ([[:alnum:]:]*).*/, + "\1", 1)); }' + fi +} + +get_ifcfg_by_device() +{ + grep -E -i -l "^[[:space:]]*DEVICE="*${1}"*[[:space:]]*$" \ + /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1 +} + +get_ifcfg_by_hwaddr() +{ + grep -E -i -l "^[[:space:]]*HWADDR="*${1}"*[[:space:]]*$" \ + /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1 +} + +get_ifcfg_by_uuid() +{ + grep -E -i -l "^[[:space:]]*UUID="*${1}"*[[:space:]]*$" \ + /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1 +} + +get_ifcfg_by_name() +{ + grep -E -i -l "^[[:space:]]*NAME="*${1}"*[[:space:]]*$" \ + /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1 +} + +is_nm_running() +{ + [ "$(LANG=C nmcli -t --fields running general status 2>/dev/null)" = "running" ] +} + +is_nm_handling() +{ + LANG=C nmcli -t --fields device,state dev status 2>/dev/null \ + | grep -q "^(${1}:connected)|(${1}:connecting.*)$" +} + +# $1: netdev name +get_ifcfg_nmcli() +{ + local nm_uuid nm_name + local ifcfg_file + + # Get the active nmcli config name of $1 + if is_nm_running && is_nm_handling "${1}" ; then + # The configuration "uuid" and "name" generated by nm is wrote to + # the ifcfg file as "UUID=<nm_uuid>" and "NAME=<nm_name>". + nm_uuid=$(LANG=C nmcli -t --fields uuid,device c show --active 2>/dev/null \ + | grep "${1}" | head -1 | cut -d':' -f1) + nm_name=$(LANG=C nmcli -t --fields name,device c show --active 2>/dev/null \ + | grep "${1}" | head -1 | cut -d':' -f1) + ifcfg_file=$(get_ifcfg_by_uuid "${nm_uuid}") + [ -z "${ifcfg_file}" ] && ifcfg_file=$(get_ifcfg_by_name "${nm_name}") + fi + + echo -n "${ifcfg_file}" +} + +# $1: netdev name +get_ifcfg_legacy() +{ + local ifcfg_file + + ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-${1}" + [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return + + ifcfg_file=$(get_ifcfg_by_name "${1}") + [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return + + local hwaddr=$(get_hwaddr "${1}") + if [ -n "$hwaddr" ]; then + ifcfg_file=$(get_ifcfg_by_hwaddr "${hwaddr}") + [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return + fi + + ifcfg_file=$(get_ifcfg_by_device "${1}") + + echo -n "${ifcfg_file}" +} + +# $1: netdev name +# Return the ifcfg file whole name(including the path) of $1 if any. +get_ifcfg_filename() { + local ifcfg_file + + ifcfg_file=$(get_ifcfg_nmcli "${1}") + if [ -z "${ifcfg_file}" ]; then + ifcfg_file=$(get_ifcfg_legacy "${1}") + fi + + echo -n "${ifcfg_file}" +}
Change all the ifcfg file users to call get_ifcfg_filename().
Signed-off-by: Xunlei Pang xlpang@redhat.com --- dracut-module-setup.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4cd7107..350864e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -66,7 +66,12 @@ kdump_is_vlan() { kdump_setup_dns() { local _nameserver _dns local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf - . /etc/sysconfig/network-scripts/ifcfg-$1 + 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" @@ -181,6 +186,8 @@ kdump_setup_bridge() { kdump_setup_bond() { local _netdev=$1 local _dev _mac _slaves _kdumpdev + local ifcfg_file + for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev) @@ -189,7 +196,12 @@ kdump_setup_bond() { done echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf # Get bond options specified in ifcfg - . /etc/sysconfig/network-scripts/ifcfg-$_netdev + + ifcfg_file=$(get_ifcfg_filename $_netdev) + if [ -f "${ifcfg_file}" ]; then + . ${ifcfg_file} + fi + bondoptions="$(echo :$BONDING_OPTS | sed 's/\s+/,/')" echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf } @@ -244,7 +256,13 @@ kdump_setup_vlan() { # $1: netdev name kdump_setup_znet() { local _options="" - . /etc/sysconfig/network-scripts/ifcfg-$1 + local ifcfg_file + + ifcfg_file=$(get_ifcfg_filename $1) + if [ -f "${ifcfg_file}" ]; then + . ${ifcfg_file} + fi + for i in $OPTIONS; do _options=${_options},$i done
Hi Xunlei,
On 25/04/2016:12:39:20 PM, Xunlei Pang wrote:
+get_hwaddr() +{
- if [ -f "/sys/class/net/${1}/address" ]; then
awk '{ print toupper($0) }' < /sys/class/net/${1}/address
- elif [ -d "/sys/class/net/${1}" ]; then
Probably if/else loop can be skipped and only having below two lines should do the job for all scenarios, no?
ip -o link show ${1} 2>/dev/null | \
awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/,
"\\1", 1)); }'
- fi
+}
~Pratyush
On 2016/04/25 at 14:42, Pratyush Anand wrote:
Hi Xunlei,
On 25/04/2016:12:39:20 PM, Xunlei Pang wrote:
+get_hwaddr() +{
- if [ -f "/sys/class/net/${1}/address" ]; then
awk '{ print toupper($0) }' < /sys/class/net/${1}/address
- elif [ -d "/sys/class/net/${1}" ]; then
Probably if/else loop can be skipped and only having below two lines should do the job for all scenarios, no?
This is originally from "/etc/sysconfig/network-scripts/network-functions", I guess it's for no ip utils existent cases.
Regards, Xunlei
ip -o link show ${1} 2>/dev/null | \
awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/,
"\\1", 1)); }'
- fi
+}
~Pratyush
Hi, Xunlei
On 04/25/16 at 12:39pm, Xunlei Pang wrote:
Previously, we assumed the ifcfg file of a network "interface" is "/etc/sysconfig/network-scripts/ifcfg-<interface>", but actually it is not the case.
For example, for network interface "enp0s25", we are able to generate like "/etc/sysconfig/network-scripts/ifcfg-enp0s25-test" for it via network-manager.
The "suffix" in "ifcfg-<suffix>" is actually a "configuration" name not "interface" name, though normally we use the "interface" name as its "configuration" name. You can refer to "man ifup" for some detail.
So, this patch adds some assistant helpers to acquire the right ifcfg file for an interface. Borrow some logic from script below: "/etc/sysconfig/network-scripts/network-functions"
Signed-off-by: Xunlei Pang xlpang@redhat.com
kdump-lib.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 4d34206..90913c5 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -230,3 +230,105 @@ is_hostname() fi echo $1 | grep -q "[a-zA-Z]" }
+get_hwaddr() +{
- if [ -f "/sys/class/net/${1}/address" ]; then
awk '{ print toupper($0) }' < /sys/class/net/${1}/address
- elif [ -d "/sys/class/net/${1}" ]; then
ip -o link show ${1} 2>/dev/null | \
awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/,
"\\1", 1)); }'
- fi
+}
I'm not sure we are using same version of Fedora, in F23 there's LC_ALL= LANG= before ip -o, ditto for other ip callback below.
If we copy the functions it may be better to keep them as is and add comments to explain these functions are copied from where to fix what issues..
eg.
# Copy /etc/sysconfig/network-scripts/network-functions functions for...
...
# End copy
+get_ifcfg_by_device() +{
- grep -E -i -l "^[[:space:]]*DEVICE="*${1}"*[[:space:]]*$" \
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+get_ifcfg_by_hwaddr() +{
- grep -E -i -l "^[[:space:]]*HWADDR="*${1}"*[[:space:]]*$" \
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+get_ifcfg_by_uuid() +{
- grep -E -i -l "^[[:space:]]*UUID="*${1}"*[[:space:]]*$" \
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+get_ifcfg_by_name() +{
- grep -E -i -l "^[[:space:]]*NAME="*${1}"*[[:space:]]*$" \
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+is_nm_running() +{
- [ "$(LANG=C nmcli -t --fields running general status 2>/dev/null)" = "running" ]
+}
+is_nm_handling() +{
- LANG=C nmcli -t --fields device,state dev status 2>/dev/null \
| grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$"
+}
+# $1: netdev name +get_ifcfg_nmcli() +{
- local nm_uuid nm_name
- local ifcfg_file
- # Get the active nmcli config name of $1
- if is_nm_running && is_nm_handling "${1}" ; then
# The configuration "uuid" and "name" generated by nm is wrote to
# the ifcfg file as "UUID=<nm_uuid>" and "NAME=<nm_name>".
nm_uuid=$(LANG=C nmcli -t --fields uuid,device c show --active 2>/dev/null \
| grep "${1}" | head -1 | cut -d':' -f1)
nm_name=$(LANG=C nmcli -t --fields name,device c show --active 2>/dev/null \
| grep "${1}" | head -1 | cut -d':' -f1)
ifcfg_file=$(get_ifcfg_by_uuid "${nm_uuid}")
[ -z "${ifcfg_file}" ] && ifcfg_file=$(get_ifcfg_by_name "${nm_name}")
- fi
- echo -n "${ifcfg_file}"
+}
+# $1: netdev name +get_ifcfg_legacy() +{
- local ifcfg_file
- ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-${1}"
- [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
- ifcfg_file=$(get_ifcfg_by_name "${1}")
- [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
- local hwaddr=$(get_hwaddr "${1}")
- if [ -n "$hwaddr" ]; then
ifcfg_file=$(get_ifcfg_by_hwaddr "${hwaddr}")
[ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
- fi
- ifcfg_file=$(get_ifcfg_by_device "${1}")
- echo -n "${ifcfg_file}"
+}
+# $1: netdev name +# Return the ifcfg file whole name(including the path) of $1 if any. +get_ifcfg_filename() {
- local ifcfg_file
- ifcfg_file=$(get_ifcfg_nmcli "${1}")
- if [ -z "${ifcfg_file}" ]; then
ifcfg_file=$(get_ifcfg_legacy "${1}")
- fi
- echo -n "${ifcfg_file}"
+}
1.8.3.1 _______________________________________________ kexec mailing list kexec@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
Thanks Dave
Hi, Xunlei
On 04/25/16 at 12:39pm, Xunlei Pang wrote:
Change all the ifcfg file users to call get_ifcfg_filename().
A bit more explanation why we should do it here, what is the problem etc..
Signed-off-by: Xunlei Pang xlpang@redhat.com
dracut-module-setup.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4cd7107..350864e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -66,7 +66,12 @@ kdump_is_vlan() { kdump_setup_dns() { local _nameserver _dns local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
- . /etc/sysconfig/network-scripts/ifcfg-$1
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"
@@ -181,6 +186,8 @@ kdump_setup_bridge() { kdump_setup_bond() { local _netdev=$1 local _dev _mac _slaves _kdumpdev
- local ifcfg_file
- for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev)
@@ -189,7 +196,12 @@ kdump_setup_bond() { done echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf # Get bond options specified in ifcfg
- . /etc/sysconfig/network-scripts/ifcfg-$_netdev
- ifcfg_file=$(get_ifcfg_filename $_netdev)
- if [ -f "${ifcfg_file}" ]; then
. ${ifcfg_file}
- fi
- bondoptions="$(echo :$BONDING_OPTS | sed 's/\s+/,/')" echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf
} @@ -244,7 +256,13 @@ kdump_setup_vlan() { # $1: netdev name kdump_setup_znet() { local _options=""
- . /etc/sysconfig/network-scripts/ifcfg-$1
- local ifcfg_file
- ifcfg_file=$(get_ifcfg_filename $1)
- if [ -f "${ifcfg_file}" ]; then
. ${ifcfg_file}
- fi
Have it been tested on other arch other than x86?
for i in $OPTIONS; do _options=${_options},$i done
-- 1.8.3.1 _______________________________________________ kexec mailing list kexec@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
Thanks Dave
On 2016/05/19 at 15:47, Dave Young wrote:
Hi, Xunlei
On 04/25/16 at 12:39pm, Xunlei Pang wrote:
Previously, we assumed the ifcfg file of a network "interface" is "/etc/sysconfig/network-scripts/ifcfg-<interface>", but actually it is not the case.
For example, for network interface "enp0s25", we are able to generate like "/etc/sysconfig/network-scripts/ifcfg-enp0s25-test" for it via network-manager.
The "suffix" in "ifcfg-<suffix>" is actually a "configuration" name not "interface" name, though normally we use the "interface" name as its "configuration" name. You can refer to "man ifup" for some detail.
So, this patch adds some assistant helpers to acquire the right ifcfg file for an interface. Borrow some logic from script below: "/etc/sysconfig/network-scripts/network-functions"
Signed-off-by: Xunlei Pang xlpang@redhat.com
kdump-lib.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 4d34206..90913c5 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -230,3 +230,105 @@ is_hostname() fi echo $1 | grep -q "[a-zA-Z]" }
+get_hwaddr() +{
- if [ -f "/sys/class/net/${1}/address" ]; then
awk '{ print toupper($0) }' < /sys/class/net/${1}/address
- elif [ -d "/sys/class/net/${1}" ]; then
ip -o link show ${1} 2>/dev/null | \
awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/,
"\\1", 1)); }'
- fi
+}
I'm not sure we are using same version of Fedora, in F23 there's LC_ALL= LANG= before ip -o, ditto for other ip callback below.
It has "LC_ALL= LANG=" originally, I will add it.
If we copy the functions it may be better to keep them as is and add comments to explain these functions are copied from where to fix what issues..
eg.
# Copy /etc/sysconfig/network-scripts/network-functions functions for...
...
# End copy
I will improve this.
Regards, Xunlei
+get_ifcfg_by_device() +{
- grep -E -i -l "^[[:space:]]*DEVICE="*${1}"*[[:space:]]*$" \
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+get_ifcfg_by_hwaddr() +{
- grep -E -i -l "^[[:space:]]*HWADDR="*${1}"*[[:space:]]*$" \
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+get_ifcfg_by_uuid() +{
- grep -E -i -l "^[[:space:]]*UUID="*${1}"*[[:space:]]*$" \
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+get_ifcfg_by_name() +{
- grep -E -i -l "^[[:space:]]*NAME="*${1}"*[[:space:]]*$" \
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+is_nm_running() +{
- [ "$(LANG=C nmcli -t --fields running general status 2>/dev/null)" = "running" ]
+}
+is_nm_handling() +{
- LANG=C nmcli -t --fields device,state dev status 2>/dev/null \
| grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$"
+}
+# $1: netdev name +get_ifcfg_nmcli() +{
- local nm_uuid nm_name
- local ifcfg_file
- # Get the active nmcli config name of $1
- if is_nm_running && is_nm_handling "${1}" ; then
# The configuration "uuid" and "name" generated by nm is wrote to
# the ifcfg file as "UUID=<nm_uuid>" and "NAME=<nm_name>".
nm_uuid=$(LANG=C nmcli -t --fields uuid,device c show --active 2>/dev/null \
| grep "${1}" | head -1 | cut -d':' -f1)
nm_name=$(LANG=C nmcli -t --fields name,device c show --active 2>/dev/null \
| grep "${1}" | head -1 | cut -d':' -f1)
ifcfg_file=$(get_ifcfg_by_uuid "${nm_uuid}")
[ -z "${ifcfg_file}" ] && ifcfg_file=$(get_ifcfg_by_name "${nm_name}")
- fi
- echo -n "${ifcfg_file}"
+}
+# $1: netdev name +get_ifcfg_legacy() +{
- local ifcfg_file
- ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-${1}"
- [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
- ifcfg_file=$(get_ifcfg_by_name "${1}")
- [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
- local hwaddr=$(get_hwaddr "${1}")
- if [ -n "$hwaddr" ]; then
ifcfg_file=$(get_ifcfg_by_hwaddr "${hwaddr}")
[ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
- fi
- ifcfg_file=$(get_ifcfg_by_device "${1}")
- echo -n "${ifcfg_file}"
+}
+# $1: netdev name +# Return the ifcfg file whole name(including the path) of $1 if any. +get_ifcfg_filename() {
- local ifcfg_file
- ifcfg_file=$(get_ifcfg_nmcli "${1}")
- if [ -z "${ifcfg_file}" ]; then
ifcfg_file=$(get_ifcfg_legacy "${1}")
- fi
- echo -n "${ifcfg_file}"
+}
1.8.3.1 _______________________________________________ kexec mailing list kexec@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
Thanks Dave
On 2016/05/19 at 15:49, Dave Young wrote:
Hi, Xunlei
On 04/25/16 at 12:39pm, Xunlei Pang wrote:
Change all the ifcfg file users to call get_ifcfg_filename().
A bit more explanation why we should do it here, what is the problem etc..
Ok, will add more explanation later.
Signed-off-by: Xunlei Pang xlpang@redhat.com
dracut-module-setup.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4cd7107..350864e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -66,7 +66,12 @@ kdump_is_vlan() { kdump_setup_dns() { local _nameserver _dns local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
- . /etc/sysconfig/network-scripts/ifcfg-$1
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"
@@ -181,6 +186,8 @@ kdump_setup_bridge() { kdump_setup_bond() { local _netdev=$1 local _dev _mac _slaves _kdumpdev
- local ifcfg_file
- for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev)
@@ -189,7 +196,12 @@ kdump_setup_bond() { done echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf # Get bond options specified in ifcfg
- . /etc/sysconfig/network-scripts/ifcfg-$_netdev
- ifcfg_file=$(get_ifcfg_filename $_netdev)
- if [ -f "${ifcfg_file}" ]; then
. ${ifcfg_file}
- fi
- bondoptions="$(echo :$BONDING_OPTS | sed 's/\s+/,/')" echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf
} @@ -244,7 +256,13 @@ kdump_setup_vlan() { # $1: netdev name kdump_setup_znet() { local _options=""
- . /etc/sysconfig/network-scripts/ifcfg-$1
- local ifcfg_file
- ifcfg_file=$(get_ifcfg_filename $1)
- if [ -f "${ifcfg_file}" ]; then
. ${ifcfg_file}
- fi
Have it been tested on other arch other than x86?
Good point, I will check the implementation and do some test on other ARCHs.
Regards, Xunlei
for i in $OPTIONS; do _options=${_options},$i done
-- 1.8.3.1 _______________________________________________ kexec mailing list kexec@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
Thanks Dave
On 2016/05/19 at 16:15, Xunlei Pang wrote:
On 2016/05/19 at 15:49, Dave Young wrote:
Hi, Xunlei
On 04/25/16 at 12:39pm, Xunlei Pang wrote:
Change all the ifcfg file users to call get_ifcfg_filename().
A bit more explanation why we should do it here, what is the problem etc..
Ok, will add more explanation later.
Signed-off-by: Xunlei Pang xlpang@redhat.com
dracut-module-setup.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4cd7107..350864e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -66,7 +66,12 @@ kdump_is_vlan() { kdump_setup_dns() { local _nameserver _dns local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
- . /etc/sysconfig/network-scripts/ifcfg-$1
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"
@@ -181,6 +186,8 @@ kdump_setup_bridge() { kdump_setup_bond() { local _netdev=$1 local _dev _mac _slaves _kdumpdev
- local ifcfg_file
- for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev)
@@ -189,7 +196,12 @@ kdump_setup_bond() { done echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf # Get bond options specified in ifcfg
- . /etc/sysconfig/network-scripts/ifcfg-$_netdev
- ifcfg_file=$(get_ifcfg_filename $_netdev)
- if [ -f "${ifcfg_file}" ]; then
. ${ifcfg_file}
- fi
- bondoptions="$(echo :$BONDING_OPTS | sed 's/\s+/,/')" echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf
} @@ -244,7 +256,13 @@ kdump_setup_vlan() { # $1: netdev name kdump_setup_znet() { local _options=""
- . /etc/sysconfig/network-scripts/ifcfg-$1
- local ifcfg_file
- ifcfg_file=$(get_ifcfg_filename $1)
- if [ -f "${ifcfg_file}" ]; then
. ${ifcfg_file}
- fi
Have it been tested on other arch other than x86?
Good point, I will check the implementation and do some test on other ARCHs.
I checked the script and also tested on ppc64 and s390, get_ifcfg_filename() can work properly like x86.
Regards, Xunlei
Regards, Xunlei
for i in $OPTIONS; do _options=${_options},$i done
-- 1.8.3.1 _______________________________________________ kexec mailing list kexec@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
Thanks Dave