forked from pool/hyper-v
- update hv_set_ifconfig further to work with our ifcfg [bnc#790469]
OBS-URL: https://build.opensuse.org/package/show/Virtualization/hyper-v?expand=0&rev=45
This commit is contained in:
parent
42570cdfd6
commit
aff955d3ed
@ -1,3 +1,8 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Nov 23 15:58:28 CET 2012 - ohering@suse.de
|
||||||
|
|
||||||
|
- update hv_set_ifconfig further to work with our ifcfg [bnc#790469]
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Thu Nov 22 18:14:12 CET 2012 - ohering@suse.de
|
Thu Nov 22 18:14:12 CET 2012 - ohering@suse.de
|
||||||
|
|
||||||
|
@ -41,43 +41,146 @@ then
|
|||||||
: expect configuration datafile as first argument
|
: expect configuration datafile as first argument
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
#
|
# send subshell output to syslog
|
||||||
(
|
(
|
||||||
|
f=/etc/sysconfig/network/scripts/functions
|
||||||
|
if test -f ${f}
|
||||||
|
then
|
||||||
|
. ${f}
|
||||||
|
else
|
||||||
|
echo "MISSING ${f}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# remove known config variables from environment
|
||||||
|
unset HWADDR
|
||||||
unset DHCP
|
unset DHCP
|
||||||
unset IF_NAME
|
unset IF_NAME
|
||||||
|
unset ${!IPADDR*}
|
||||||
|
unset ${!NETMASK*}
|
||||||
|
unset ${!GATEWAY*}
|
||||||
|
unset ${!IPV6ADDR*}
|
||||||
|
unset ${!IPV6NETMASK*}
|
||||||
|
unset ${!IPV6_DEFAULTGW*}
|
||||||
|
unset ${!DNS*}
|
||||||
. "$1"
|
. "$1"
|
||||||
|
#
|
||||||
if test -z "${IF_NAME}"
|
if test -z "${IF_NAME}"
|
||||||
then
|
then
|
||||||
echo "Missing IF_NAME= in ${cfg}"
|
echo "Missing IF_NAME= in ${cfg}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
#
|
#
|
||||||
t=`mktemp`
|
t_ifcfg=`mktemp`
|
||||||
if test -z "${t}"
|
t_ifroute=`mktemp`
|
||||||
then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
_exit() {
|
_exit() {
|
||||||
rm -f "${t}"
|
rm -f "${t_ifcfg}" "${t_ifroute}"
|
||||||
}
|
}
|
||||||
trap _exit EXIT
|
trap _exit EXIT
|
||||||
#
|
#
|
||||||
cat >> "${t}" <<_EOF_
|
if test -z "${t_ifcfg}" || test -z "${t_ifroute}"
|
||||||
# contents from $0 $*
|
|
||||||
`cat "${cfg}"`
|
|
||||||
#
|
|
||||||
# additional options:
|
|
||||||
STARTMODE=auto
|
|
||||||
_EOF_
|
|
||||||
|
|
||||||
if test "${DHCP}" = "yes"
|
|
||||||
then
|
then
|
||||||
echo "BOOTPROTO=dhcp" >> ${t};
|
exit 1
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
# Create ifcfg-* file
|
||||||
|
(
|
||||||
|
echo "STARTMODE=auto"
|
||||||
|
#
|
||||||
|
if test -n "${HWADDR}"
|
||||||
|
then
|
||||||
|
: # ignore HWADDR, it just repeats the existing MAC value
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
if test "${DHCP}" = "yes"
|
||||||
|
then
|
||||||
|
echo "BOOTPROTO=dhcp"
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
# loop through all ipv4 adresses
|
||||||
|
for var in ${!IPADDR*}
|
||||||
|
do
|
||||||
|
index=${var#IPADDR}
|
||||||
|
pfx=
|
||||||
|
# find corresponding NETMASK variable
|
||||||
|
eval nm=\$NETMASK${index}
|
||||||
|
# if specified, calculate prefix
|
||||||
|
if test -n "${nm}"
|
||||||
|
then
|
||||||
|
pfx=`mask2pfxlen "${nm}" 2>/dev/null`
|
||||||
|
fi
|
||||||
|
# construct actual value
|
||||||
|
eval val=\$IPADDR${index}
|
||||||
|
# append prefix to value
|
||||||
|
if test -n "${pfx}"
|
||||||
|
then
|
||||||
|
val="${val}/${pfx}"
|
||||||
|
fi
|
||||||
|
# write config variable
|
||||||
|
echo "IPADDR${index}='${val}'"
|
||||||
|
done
|
||||||
|
# loop through all ipv6 adresses
|
||||||
|
for var in ${!IPV6ADDR*}
|
||||||
|
do
|
||||||
|
index=${var#IPV6ADDR}
|
||||||
|
pfx=
|
||||||
|
# find corresponding IPV6NETMASK variable
|
||||||
|
eval nm=\$IPV6NETMASK${index}
|
||||||
|
# if specified, calculate prefix
|
||||||
|
if test -n "${nm}"
|
||||||
|
then
|
||||||
|
pfx=`mask2pfxlen "${nm}" 2>/dev/null`
|
||||||
|
fi
|
||||||
|
# construct actual value
|
||||||
|
eval val=\$IPV6ADDR${index}
|
||||||
|
# append prefix to value
|
||||||
|
if test -n "${pfx}"
|
||||||
|
then
|
||||||
|
val="${val}/${pfx}"
|
||||||
|
fi
|
||||||
|
# write config variable
|
||||||
|
echo "IPV6ADDR${index}='${val}'"
|
||||||
|
done
|
||||||
|
|
||||||
|
) >> "${t_ifcfg}"
|
||||||
|
|
||||||
|
# Create ifroute-* file
|
||||||
|
(
|
||||||
|
if test -n "${GATEWAY}"
|
||||||
|
then
|
||||||
|
echo "default $GATEWAY - $IF_NAME"
|
||||||
|
fi
|
||||||
|
if test -n "${IPV6_DEFAULTGW}"
|
||||||
|
then
|
||||||
|
echo "default $IPV6_DEFAULTGW - $IF_NAME"
|
||||||
|
fi
|
||||||
|
) >> "${t_ifroute}"
|
||||||
|
# Only a single default gateway is supported
|
||||||
|
unset GATEWAY IPV6_DEFAULTGW
|
||||||
|
if test -n "${!GATEWAY*}${!IPV6_DEFAULTGW*}"
|
||||||
|
then
|
||||||
|
echo "WARNING: multiple gateways not supported: ${!GATEWAY*} ${!IPV6_DEFAULTGW*}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# collect DNS info
|
||||||
|
_DNS_=
|
||||||
|
for var in ${!DNS*}
|
||||||
|
do
|
||||||
|
eval val=\$${var}
|
||||||
|
if test -n "${_DNS_}"
|
||||||
|
then
|
||||||
|
_DNS_="${_DNS_} ${val}"
|
||||||
|
else
|
||||||
|
_DNS_=${val}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
#
|
||||||
echo "$0: working on network interface ifcfg-${IF_NAME}"
|
echo "$0: working on network interface ifcfg-${IF_NAME}"
|
||||||
cp -b ${t} "/etc/sysconfig/network/ifcfg-${IF_NAME}"
|
cp -fb ${t_ifcfg} "/etc/sysconfig/network/ifcfg-${IF_NAME}"
|
||||||
|
cp -fb ${t_ifroute} "/etc/sysconfig/network/ifroute-${IF_NAME}"
|
||||||
|
if test -n "${_DNS_}" && test -w /etc/sysconfig/network/config
|
||||||
|
then
|
||||||
|
sed -i "s@^NETCONFIG_DNS_STATIC_SERVERS=.*@NETCONFIG_DNS_STATIC_SERVERS='$_DNS_'@" /etc/sysconfig/network/config
|
||||||
|
fi
|
||||||
ifdown "${IF_NAME}" -o hotplug
|
ifdown "${IF_NAME}" -o hotplug
|
||||||
ifup "${IF_NAME}" -o hotplug
|
ifup "${IF_NAME}" -o hotplug
|
||||||
) 2>&1 | logger -t "${0##*/}[$PPID / $$]"
|
) 2>&1 | logger -t "${0##*/}[$PPID / $$]"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user