#!/bin/sh
# -*- Mode: shell-script -*-

[ -e /etc/sysconfig/apmd ] && . /etc/sysconfig/apmd

# Unload sound modules if necessary
if [ "$RESTORESOUND" = "yes" -o "$RESTORESOUNDPROGS" = "yes" ]; then
    # soundoff is from the commercial OSS drivers, don't worry
    # if you don't have it. (Nobody sane does ;) ).
    [ -x /usr/bin/soundoff ] && /usr/bin/soundoff
    [ -x /usr/sbin/soundoff ] && /usr/sbin/soundoff
    [ -x /usr/local/bin/soundoff ] && /usr/local/bin/soundoff
    [ -x /usr/local/sbin/soundoff ] && /usr/local/sbin/soundoff
    rm -rf /var/run/apm-soundmodules
    for m in $SOUNDMODULES; do
	if lsmod |grep -q "^$m " &>/dev/null; then
	    rmmod $m
	    echo $m >>/var/run/apm-soundmodules
	fi
    done
fi
sync
