Skip to content
Snippets Groups Projects
Commit eaa6e2e1 authored by Giuseppe Attardi's avatar Giuseppe Attardi
Browse files

Update install

parent 830306ca
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ set -e ...@@ -8,7 +8,7 @@ set -e
status-set maintenance "Changing Default gateway" status-set maintenance "Changing Default gateway"
GATEWAY="$(config-get 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'}` GATEWAY_IP=`echo "$GATEWAY" | awk -F "/" {'print $1'}`
if [ -z "$GATEWAY" ]; then if [ -z "$GATEWAY" ]; then
...@@ -24,26 +24,26 @@ if [ "$GATEWAY_IP" == "$OLD_GATEWAY_IP" ]; then ...@@ -24,26 +24,26 @@ if [ "$GATEWAY_IP" == "$OLD_GATEWAY_IP" ]; then
fi fi
apt-get install -y sipcalc apt install -y sipcalc
GATEWAY_NET=`sipcalc $GATEWAY | grep "Network address" | awk '{print $4}'` GATEWAY_NET=`sipcalc $GATEWAY | grep "Network address" | awk '{print $4}'`
old_IFS=$IFS old_IFS=$IFS
IFS=$'\n' IFS=$'\n'
LINE=0 LINE=0
for INTERFACE in $(cat -n /etc/network/interfaces | grep address); for INTERFACE in $(grep adress /etc/network/interfaces);
do do
ADDRESS=`echo $INTERFACE | awk '{ print $3}'` ADDRESS=`echo $INTERFACE | awk '{ print $3}'`
ADDRESS_NET=`sipcalc $ADDRESS | grep "Network address" | awk '{print $4}'` ADDRESS_NET=`sipcalc $ADDRESS | grep "Network address" | awk '{print $4}'`
if [ "$ADDRESS_NET" == "$GATEWAY_NET" ]; then if [ "$ADDRESS_NET" == "$GATEWAY_NET" ]; then
LINE=`echo $INTERFACE | awk '{ print $1}'` LINE=`address'`
fi fi
done done
IFS=$old_IFS IFS=$old_IFS
if [ "$LINE" -gt 0 ]; then if [ "$LINE" -gt 0 ]; then
juju-log "Default gateway $GATEWAY_IP is setting..." 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 if [ ! -z "$OLD_GATEWAY_IP" ]; then
juju-log "Old default gateway $OLD_GATEWAY_IP removing..." juju-log "Old default gateway $OLD_GATEWAY_IP removing..."
sed -i "/${OLD_GATEWAY_IP}/d" /etc/network/interfaces sed -i "/${OLD_GATEWAY_IP}/d" /etc/network/interfaces
......
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