#
# Otu shell functions
#
#

# Return 1 if cotu hw is present
is_cotu_hw () {
   if [ -f /proc/device-tree/board/info-otu-board ] && [ $(hexdump /proc/device-tree/board/info-otu-board -n 4 -e '"%d"') -eq "3" ] ; then
        return 1
   else
        return 0
   fi
}

# Return 1 if SW OTU is enabled
is_otu_sw () {
    ENV_OTU_SW=$(fw_printenv otu_sw_enable 2>/dev/null | cut -d = -f 2)
    if [ "$ENV_OTU_SW" == "1" ] ; then
        return 1
    else
        return 0
    fi
}

quit_if_not_using_otu () {
    is_cotu_hw
    if [ $? -eq 0 ] ; then
        is_otu_sw
        if [ $? -eq 0 ] ; then
            exit 0
        fi
    fi
}

otu_log () {
    echo "$(date +'%B %d %H:%M:%S') $(hostname) $1:  . $2" >> /var/log/user.log
}
