#!/bin/sh

# if there is a partner controller, the CPLD Mated bit (bit 7) is set
if [ $(($(cat /proc/moose/cpld/slot_info) & 0x80)) -eq $((0x80)) ]
then
    # Restart the slip network
    logger "Restarting slip.."
    ifconfig sl0 down
    killall -9 slattach
    sleep 2
    slattach -L -F -s 115200 -p cslip /dev/ttyS1 &
    sleep 2
    # if yes, then let's restart slip network
    A_SL_IP=$( xmlcntrl /etc/networking.xml CONTROLLER_A sl0_ip )
    B_SL_IP=$( xmlcntrl /etc/networking.xml CONTROLLER_B sl0_ip )
    mc=`readslot`
    if [ "$mc" == "A" ]
    then
        ifconfig sl0  $A_SL_IP pointopoint $B_SL_IP up
    else
        ifconfig sl0  $B_SL_IP pointopoint $A_SL_IP up
    fi
fi
