From eaa6e2e1cedf08ef514f4abf84ef8aabe0168728 Mon Sep 17 00:00:00 2001 From: Giuseppe Attardi <giuseppe.attardi@garr.it> Date: Fri, 19 Jan 2018 10:22:00 +0100 Subject: [PATCH] Update install --- hooks/install | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hooks/install b/hooks/install index 8cacc17..0f129e6 100644 --- a/hooks/install +++ b/hooks/install @@ -8,7 +8,7 @@ set -e status-set maintenance "Changing Default gateway" GATEWAY="$(config-get gateway)" -OLD_GATEWAY_IP=`cat /etc/network/interfaces | grep gateway | awk '{print $2}'` +OLD_GATEWAY_IP=`grep gateway /etc/network/interfaces | awk '{print $2}'` GATEWAY_IP=`echo "$GATEWAY" | awk -F "/" {'print $1'}` if [ -z "$GATEWAY" ]; then @@ -24,26 +24,26 @@ if [ "$GATEWAY_IP" == "$OLD_GATEWAY_IP" ]; then fi -apt-get install -y sipcalc +apt install -y sipcalc GATEWAY_NET=`sipcalc $GATEWAY | grep "Network address" | awk '{print $4}'` old_IFS=$IFS IFS=$'\n' LINE=0 -for INTERFACE in $(cat -n /etc/network/interfaces | grep address); +for INTERFACE in $(grep adress /etc/network/interfaces); do ADDRESS=`echo $INTERFACE | awk '{ print $3}'` ADDRESS_NET=`sipcalc $ADDRESS | grep "Network address" | awk '{print $4}'` if [ "$ADDRESS_NET" == "$GATEWAY_NET" ]; then - LINE=`echo $INTERFACE | awk '{ print $1}'` + LINE=`address'` fi done IFS=$old_IFS if [ "$LINE" -gt 0 ]; then juju-log "Default gateway $GATEWAY_IP is setting..." - sed -i "${LINE}i\ gateway $GATEWAY_IP" /etc/network/interfaces + sed -i "/address/i\ gateway $GATEWAY_IP" /etc/network/interfaces if [ ! -z "$OLD_GATEWAY_IP" ]; then juju-log "Old default gateway $OLD_GATEWAY_IP removing..." sed -i "/${OLD_GATEWAY_IP}/d" /etc/network/interfaces -- GitLab