#!/bin/sh
#
# alsa-drivers initscript
#
### BEGIN INIT INFO
# Provides:          alsa-drivers
# Required-Start:    
# Required-Stop:     
# Default-Start:     
# Default-Stop:      0 6
# Short-Description: Unloads Intel ALSA HDA driver
# Description:       This script unloadds the Intel ALSA HDA
#                    driver ( snd_hda_intel ) on shutdown and
#                    reboot to prevent crackling noise.
### END INIT INFO

# Don't use set -e; check exit status instead

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MYNAME=/etc/init.d/alsa-drivers

. /lib/lsb/init-functions

# $1 EXITSTATUS
# [$2 MESSAGE]
log_action_end_msg_and_exit()
{
	log_action_end_msg "$1" "$2" 
        echo "$1" "$2"
	exit $1
}

case "$1" in
  start|stop)
	EXITSTATUS=0
	/sbin/rmmod -f snd_hda_intel
	log_action_end_msg_and_exit "$EXITSTATUS"
	;;
  restart|force-reload|start|reset)
        EXITSTATUS=1
        log_action_end_msg_and_exit "$EXITSTATUS"
	exit $EXITSTATUS
	;;
  *)
	echo "Usage: $MYNAME {stop}" >&2
	exit 3
	;;
esac

