#!/bin/sh

. /usr/lib/board-scripts/common-functions.sh

usage() {
    cat <<EOF;
Usage:
    board-probe list        List all supported boards
    board-probe show        Print the name of the detected board
                            based on IPAM HW_TYPE
    board-probe BOARD       Exits with TRUE if running on BOARD.
                            Otherwise exists with FALSE.
EOF
}



if [ $# -ne 1 ]; then
    usage 1>&2
    exit 1
fi

case $1 in
    list)
        echo "Supported boards (HW_TYPE)"
        echo "  m400    (54)"
        echo "  s400    (59)"
        echo "  sp400   (65)"
        echo "  tpa400  (66)"
        echo "  mpi400  (73)"
        echo "  lox400  (76)"
        echo "  m41     (77)"
        echo "  unigate (81)"
        echo "  mr400   (83)"
        echo "  tpa411  (95)"
        ;;

    show)
        HW_TYPE=$(qiba-spi-get-production-info.sh -w)
        get_board_name $HW_TYPE
        ;;

    *)
        HW_TYPE=$(qiba-spi-get-production-info.sh -w)
        BOARD_NAME=$(get_board_name "$HW_TYPE")
        test "$BOARD_NAME" = "$1"
esac
