#!/bin/bash
 
IF=$1
STATUS=$2
 
if [ "$IF" == "eth0" ]
then
    case "$2" in
        up)
        logger -s "NM Eth0 Script up triggered"
        #assign the static IP address for slingshot
        #TODO:: can we check if eth0 has been brough up on a 10.X.X network and skip this to not break things??
		if [ "${IP4_ADDRESS_0}" == "10.1.1.1/24 0.0.0.0" ]; then
			logger -s "Skipping eth0:0 creation, server detected"
		else
	        ifconfig eth0:0 10.1.1.2 netmask 255.255.255.0 up
		fi
        ;;
        down)
		#todo:: sometimes this is getting called after the link goes down... how can we fix that
        logger -s "NM Eth0 Script down triggered"
        set +e 
        ifconfig eth0:0 down
        logger -s "NM Eth0 Script down completed"
        ;;
        pre-up)
        logger -s "NM Eth0 Script pre-up triggered"
        #command
        ;;
        post-down)
        logger -s "NM Eth0 Script post-down triggered"
        #command
        ;;
        *)
        ;;
    esac
fi
