From bd5ac2b0351eaef215dbedf7ec3090d0ba461d10 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 24 Jul 2014 17:10:44 +0200 Subject: [PATCH] gh-2: Use GATEWAY_IFACE in rhel network --- base_rpm/etc/one-context.d/00-network | 35 +++++++++++++++++++++------ 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/base_rpm/etc/one-context.d/00-network b/base_rpm/etc/one-context.d/00-network index ba8e81c..967bc32 100755 --- a/base_rpm/etc/one-context.d/00-network +++ b/base_rpm/etc/one-context.d/00-network @@ -52,18 +52,35 @@ get_mask() { echo $mask } +is_gateway() { + if [ -z "$GATEWAY_IFACE_NUM" ]; then + true + else + [ "$IFACE_NUM" = "$GATEWAY_IFACE_NUM" ] + fi +} + # Gets the network gateway get_gateway() { - gateway=$(get_iface_var "GATEWAY") - - if [ -z "$gateway" ]; then - if [ "$DEV" = "eth0" ]; then - net_prefix=$(echo $NETWORK | cut -d'.' -f1,2,3) - gateway="${net_prefix}.1" + if is_gateway; then + gateway=$(get_iface_var "GATEWAY") + + if [ -z "$gateway" ]; then + if [ "$DEV" = "eth0" ]; then + net_prefix=$(echo $NETWORK | cut -d'.' -f1,2,3) + gateway="${net_prefix}.1" + fi fi + + echo $gateway fi +} - echo $gateway +# Gets the network gateway6 +get_gateway6() { + if is_gateway; then + get_iface_var "GATEWAY6" + fi } get_ip() { @@ -131,11 +148,13 @@ gen_network_configuration() { INTERFACE_MAC=$(get_interface_mac) CONTEXT_INTERFACES=$(get_context_interfaces) + GATEWAY_IFACE_NUM=$(echo "$GATEWAY_IFACE" | sed 's/^ETH//') for interface in $CONTEXT_INTERFACES; do UPCASE_DEV=$interface MAC=$(get_iface_var "MAC") DEV=$(get_dev "$INTERFACE_MAC" "$MAC") + IFACE_NUM=$(echo "$UPCASE_DEV" | sed 's/^ETH//') IP=$(get_ip) NETWORK=$(get_network) @@ -144,7 +163,7 @@ gen_network_configuration() IPV6=$(get_iface_var "IPV6") [[ -z $IPV6 ]] && IPV6=$(get_iface_var "IP6") - GATEWAY6=$(get_iface_var "GATEWAY6") + GATEWAY6=$(get_gateway6) CONTEXT_FORCE_IPV4=$(get_iface_var "CONTEXT_FORCE_IPV4") (