#!/usr/bin/bash

# This file must contain all required operations for booting the MOD.
# This script is called by systemd as an oneshot service just after data-partition-operations.service.

# ---------------------------------------------------------------------------------------------------------------------
# initialize hardware details

/usr/bin/mod-hardware init

# ---------------------------------------------------------------------------------------------------------------------
# restore alsa values
# NOTE: this does not change true-bypass and loopback state

SKIP_HW_DESC_INIT=1
source /etc/mod-hardware-descriptor.env

if [ -f /data/asound.state ] && (/usr/sbin/alsactl restore ${SOUNDCARD} -f /data/asound.state); then
    /usr/bin/echo "ALSA: restored user settings"
else
    /usr/bin/echo "ALSA: restored default values"
    /usr/sbin/alsactl restore ${SOUNDCARD} -f /usr/share/mod/asound.state
fi

# ---------------------------------------------------------------------------------------------------------------------
# always exit cleanly, other services depend on this one

exit 0

# ---------------------------------------------------------------------------------------------------------------------
