#!/bin/sh
# chkconfig: 2345 50 50
### BEGIN INIT INFO
# Provides:          unmute-sound-card
# Required-Start:    sound
# Required-Stop:     sound
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start unmute-sound-card at boot time
# Description:       Enable service provided by unmute-sound-card.
# X-Start-Before:    
# X-Stop-After:      
# X-Timesys-Start-Number:  50
# X-Timesys-Stop-Number:  50
### END INIT INFO

# unmute the sound card at boot

start()
{
  if [ -n "$(amixer scontrols | grep PCM)" ]; then
      CONTROL=PCM
  elif [ -n "$(amixer scontrols | grep Master)" ]; then
      CONTROL=Master
  fi

  if [ -n "$CONTROL" ]; then
      echo -n "Unmuting sound device: "
      amixer sset $CONTROL,0 100% > /tmp/`basename $0`.log 2>&1 && \
          echo '[ OK ]' || echo '[FAIL]'
  fi      

}

case "$1" in
  start)
    start
  ;;
  *)
  ;;
esac
