#!/bin/bash

APPNAME=marmaserver
APPDIR=/opt/midas/bin
MODE=${1}
IPADDRESS=${2}

# figure out which network device to use
if [ -n "`ip addr | grep inet | grep bond0`" ]; then
    # DL3/XL8 use bonded eth0/1
    NETWORKDEVICE=bond0
else
    # DL1/2 use two separate ports
    NETWORKDEVICE=eth1
fi

# function for DL2/DL1 where eth0/1 are bridged by default
function rebuildBridge
{
    # simple DL1/2 test
    if [ ${NETWORKDEVICE} == "eth1" ]; then
        brctl addif br0 ${NETWORKDEVICE}
    fi
}

# switch to standby - i.e. dump external ip addresses
${APPDIR}/set-marmaserver-mode standby
pkill dhcpcd
pkill ${APPNAME}
rebuildBridge

