#!/bin/sh

if [ "$METHOD" == "manual" ]; then
    exec 1>/dev/ttyAMA0
    exec 2>/dev/ttyAMA0

    # Get the network settings from the netsettings.sh script
    source /app/bin/netsettings.sh

    # Are we using static or DHCP for the network?
    if [ "$NET_MODE" == "dhcp" ]; then
        echo S01ifconfig: DHCP Mode

        # Stop DHCP if it is started
        if [ -f /var/run/udhcpc.$IFACE.pid ]; then
            kill $(cat /var/run/udhcpc.$IFACE.pid)
        fi
        
        # Bring the interface down
        ifconfig $IFACE down
    else
        # Static mode
        echo S01ifconfig: Static Mode

        # Bring the interface down
        ifconfig $IFACE down
    fi        
fi
