summaryrefslogtreecommitdiff
path: root/audio/emu10kx/pkg-install
blob: 1eb82b4a0108bf5e7d27a2decd7cd823109a6728 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh

[ "$2" != "POST-INSTALL" ] && exit 0

#============================================================
# POST-INSTALL
#============================================================
DRIVERNAME=snd_emu10kx

# Ask user about installing driver
echo -n "Do you want to install $DRIVERNAME driver and load it on boot time? [y/n]: "
read RES
echo

if [ x"$RES" = x"y" ] ; then

# Unload the driver
kldstat -n $DRIVERNAME > /dev/null 2>&1; RESULT=$?
if [ ${RESULT} -eq 0 ]; then
	kldunload -n $DRIVERNAME > /dev/null 2>&1; RESULT=$?
	if [ ${RESULT} -ne 0 ]; then
		echo "ERROR: Failed to unload the $DRIVERNAME module!"
		echo "ERROR: Is $DRIVERNAME.ko in use?"
		exit 1;
	fi
fi

# Load the driver
kldload $DRIVERNAME > /dev/null 2>&1 ; RESULT=$?
if [ ${RESULT} -ne 0 ]; then
	echo "ERROR: Failed to load the $DRIVERNAME module!"
	exit 1;
fi

# Have the driver load at boot
grep ${DRIVERNAME}_load /boot/loader.conf > /dev/null 2>&1; RESULT=$?
if [ ${RESULT} -eq 0 ]; then
	# Present.
	sed -e "s/${DRIVERNAME}_load.*/${DRIVERNAME}_load=\"YES\"/g" -i.orig /boot/loader.conf
else
	# Not present.
	echo "${DRIVERNAME}_load=\"YES\"" >> /boot/loader.conf
fi

fi
#============================================================