B #83: Fix route metrics for CentOS

+ small refactor
+ fix whitespace

Signed-off-by: Petr Ospalý <pospaly@opennebula.io>
pull/211/head
Petr Ospalý 5 years ago committed by Vlastimil Holer
parent 3de259bf83
commit a8bed00766

@ -99,6 +99,7 @@ if [ -d /etc/sysconfig/network-scripts ]; then
# Prepare network files
find /etc/sysconfig/network-scripts -type f \
-name 'ifcfg-*' ! -name 'ifcfg-lo' \
-o -name 'route-*' ! -name 'route-lo' \
-exec rm -f {} \;
if [ "${NETWORK_EC2}" = 'yes' ]; then

@ -108,13 +108,11 @@ EOT
if [ -n "$GATEWAY" ]; then
if [ "$CONFIG_PATH" = "/etc/sysconfig/network" ]; then
echo "default $GATEWAY - $DEV" ${METRIC:+metric ${METRIC}} >> /etc/sysconfig/network/ifroute-$DEV
echo "default $GATEWAY - $DEV ${METRIC:+metric ${METRIC}}" \
>> "${CONFIG_PATH}/ifroute-${DEV}"
else
echo "GATEWAY=$GATEWAY"
if [ -n "$METRIC" ]; then
echo "METRIC=$METRIC"
fi
echo "default via $GATEWAY dev $DEV ${METRIC:+metric ${METRIC}}" \
>> "${CONFIG_PATH}/route-${DEV}"
fi
fi
@ -244,6 +242,7 @@ gen_network_configuration()
[ -z "${DEV}" ] && continue
(
rm -f /etc/sysconfig/network-scripts/route-$DEV
rm -f /etc/sysconfig/network/ifroute-$DEV
rm -f /etc/sysconfig/network/ifsysctl-$DEV

@ -93,9 +93,9 @@ for pci in $PCI_INTERFACES; do
if [ -n "$IP" ]; then
ip address add $IP/$MASK dev $DEV
if [ -n "$GATEWAY" ]; then
ip route add default via $GATEWAY dev $DEV ${METRIC:+metric ${METRIC}}
fi
if [ -n "$GATEWAY" ]; then
ip route add default via $GATEWAY dev $DEV ${METRIC:+metric ${METRIC}}
fi
fi
# IPv6

Loading…
Cancel
Save