#!/bin/sh

. /etc/oss.conf

if /sbin/modadmin -Q osscore >> /dev/null 2>&1
then
  OK=1
else
  echo OSS not loaded.
  exit 0
fi

if test ! -f $OSSLIBDIR/etc/installed_drivers
then
	echo $OSSLIBDIR/etc/installed_drivers is missing.
	exit 1
fi

# Save mixer settings automatically if requested
if test -f $OSSLIBDIR/etc/userdefs && /usr/bin/grep -q "autosave_mixer yes" $OSSLIBDIR/etc/userdefs
then
	/usr/sbin/savemixer 
fi

for n in `cat $OSSLIBDIR/etc/installed_drivers | sed 's/#.*//'`
do
    /sbin/modadmin -U $n > /dev/null 2>&1
done

/sbin/modadmin -U osscore > /dev/null 2>&1

if /sbin/modadmin -Q osscore >> /dev/null 2>&1
then
  OK=1
else
  exit 0
fi

echo Cannot unload the OSS driver modules

exit 0
