Skip to content
Snippets Groups Projects
Commit 55d9d913 authored by Claudio Pisa's avatar Claudio Pisa
Browse files

improve readability

parent 3584dd2a
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment