diff --git a/hooks/install b/hooks/install index d96661fe35133408ce5c368f6d4eab2806762175..0351885cc320ce6c68df3add4dafd603d6f4d211 100644 --- a/hooks/install +++ b/hooks/install @@ -5,7 +5,7 @@ set -x status-set maintenance "Setting the default gateway" -GATEWAY="$(config-get gateway)" +GATEWAY="$( config-get gateway )" if [ -z "$GATEWAY" ]; then juju-log "Gateway option is empty. Exiting..." @@ -13,22 +13,31 @@ if [ -z "$GATEWAY" ]; then exit 0 fi -GATEWAY_IP=`echo "$GATEWAY" | awk -F "/" '{print $1}'` +GATEWAY_IP="$( echo "$GATEWAY" | awk -F "/" '{print $1}' )" source /etc/lsb-release -RELEASE_MAJOR="$(echo $DISTRIB_RELEASE | awk -F '.' '{print $1}')" +RELEASE_MAJOR="$( echo $DISTRIB_RELEASE | awk -F '.' '{print $1}' )" if [ "$RELEASE_MAJOR" -le "16" ]; then + # Ubuntu release is less or equal than trusty # copy metric 0 routes to routes with metric 1 - ip route show | grep "^default" | grep -v metric | while read line; do ip route append $line metric 1 || true; done + ip route show | grep "^default" | grep -v metric | while read line; do + ip route append $line metric 1 || true + done # delete metric 0 routes - ip route show | grep "^default" | grep -v metric | while read line; do ip route del $line metric 0; done -else # release is not less or equal than trusty + ip route show | grep "^default" | grep -v metric | while read line; do + ip route del $line metric 0 + done +else # copy metric 0 routes to routes with metric 1 - ip route show default metric 0 | while read line; do ip route append $line metric 1 || true; done + ip route show default metric 0 | while read line; do + ip route append $line metric 1 || true + done # delete metric 0 routes - ip route show default metric 0 | while read line; do ip route del $line metric 0; done + ip route show default metric 0 | while read line; do + ip route del $line metric 0 + done fi # add our route