#!/bin/sh
### BEGIN INIT INFO
# Provides:          asound-board-detect
# Required-Start:    $local_fs mountvirtfs
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Detect board and setup asound.conf
# Description:       Detect board and setup asound.conf
### END INIT INFO

. /etc/default/rcS

case "$1" in
	start|"")
		test "$VERBOSE" != no && echo "Initializing asound.conf based on board detection..."

		[ -e /proc/device-tree/sue/carrierboard ] && CARRIER=`cat /proc/device-tree/sue/carrierboard`
		[ -e /proc/device-tree/sue/daughterboard ] && DAUGHTER=`cat /proc/device-tree/sue/daughterboard`

		if [ -n "$CARRIER" -a -f /etc/asound-${CARRIER}.conf ]; then
			echo "</etc/asound-${CARRIER}.conf>"
			[ -n "$DAUGHTER" -a -f /etc/asound-${CARRIER}-${DAUGHTER}.conf ] && echo "</etc/asound-${CARRIER}-${DAUGHTER}.conf>"
		fi > /tmp/asound-board-detect.conf
		;;

	stop)
		;;

	*)
		echo "Usage: asound-board-detect {start}" >&2
		exit 1
		;;
esac

exit 0
