summaryrefslogtreecommitdiff
path: root/setup/Linux/oss/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'setup/Linux/oss/scripts')
-rw-r--r--setup/Linux/oss/scripts/90-oss_usb-create-device.fdi8
-rwxr-xr-xsetup/Linux/oss/scripts/killprocs.sh17
-rw-r--r--setup/Linux/oss/scripts/oss_usb-create-devices4
-rw-r--r--setup/Linux/oss/scripts/remove_drv.sh164
-rw-r--r--setup/Linux/oss/scripts/restore_drv.sh63
-rw-r--r--setup/Linux/oss/scripts/setup-alsa.sh32
-rwxr-xr-xsetup/Linux/oss/scripts/showprocs.sh28
7 files changed, 316 insertions, 0 deletions
diff --git a/setup/Linux/oss/scripts/90-oss_usb-create-device.fdi b/setup/Linux/oss/scripts/90-oss_usb-create-device.fdi
new file mode 100644
index 0000000..28744f9
--- /dev/null
+++ b/setup/Linux/oss/scripts/90-oss_usb-create-device.fdi
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deviceinfo version="0.2">
+ <device>
+ <match key="info.linux.driver" string="oss_usb">
+ <append key="info.callouts.add" type="strlist">oss_usb-create-devices</append>
+ </match>
+ </device>
+</deviceinfo>
diff --git a/setup/Linux/oss/scripts/killprocs.sh b/setup/Linux/oss/scripts/killprocs.sh
new file mode 100755
index 0000000..ce8d26d
--- /dev/null
+++ b/setup/Linux/oss/scripts/killprocs.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+PROCS="`fuser /dev/mixer* /dev/dsp* /dev/audio* /dev/sequencer /dev/music /dev/midi* 2>/dev/null`"
+
+if test "$PROCS " = " "
+then
+ exit 0
+fi
+
+for pid in $PROCS
+do
+ #ps ax|grep "^ *$pid "
+ echo killing $pid
+ kill $pid
+done
+
+sleep 2
+exit 0
diff --git a/setup/Linux/oss/scripts/oss_usb-create-devices b/setup/Linux/oss/scripts/oss_usb-create-devices
new file mode 100644
index 0000000..a6de13c
--- /dev/null
+++ b/setup/Linux/oss/scripts/oss_usb-create-devices
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+/usr/sbin/ossdetect -d
+/usr/sbin/ossdevlinks
diff --git a/setup/Linux/oss/scripts/remove_drv.sh b/setup/Linux/oss/scripts/remove_drv.sh
new file mode 100644
index 0000000..55cc1b4
--- /dev/null
+++ b/setup/Linux/oss/scripts/remove_drv.sh
@@ -0,0 +1,164 @@
+#!/bin/sh
+if test -f /etc/oss.conf
+then
+ . /etc/oss.conf
+else
+ OSSLIBDIR=/usr/lib/oss
+fi
+
+# This script wipes out the previously installed sound drivers
+# from the system.
+
+# Backup all kernel sound drivers (ALSA) and remove the kernel/sound
+# directory from the system. Untar the backup package to return ALSA
+# back in business.
+
+if test -x /sbin/chkconfig
+then
+ /sbin/chkconfig alsasound off > /dev/null 2>&1
+elif test -x /usr/sbin/update-rc.d
+then
+ /usr/sbin/update-rc.d -f alsa-utils remove > /dev/null 2>&1
+elif test -x /usr/sbin/alsa
+then
+ /usr/sbin/alsa force-unload > /dev/null 2>&1
+fi
+
+if test -d /lib/modules/`uname -r`/kernel/sound
+then
+ if ! test -f /lib/modules/`uname -r`/sound-preoss.tar.bz2
+ then
+ (cd /lib/modules/`uname -r`; tar cfj /lib/modules/`uname -r`/sound-preoss.tar.bz2 kernel/sound)
+ fi
+
+ rm -rf /lib/modules/`uname -r`/kernel/sound
+ depmod -a
+fi
+
+# Kill all applications using ALSA or OSS/Free devices
+
+# We have to use ugly replacement of fuser since this command got broken
+# in some Linux recent distributions.
+
+KILL=0
+
+for n in /proc/[0-9]*
+do
+ PID=`basename $n`
+ if test "`ls -l $n/fd/* 2>/dev/null|grep /dev/snd` " != " "
+ then
+ KILL=1
+ fi
+
+ if test "`ls -l $n/fd/* 2>/dev/null|grep /dev/mixer` " != " "
+ then
+ KILL=1
+ fi
+done
+
+if ! test -d $OSSLIBDIR/save
+then
+ mkdir $OSSLIBDIR/save
+fi
+
+if test "$KILL " = "1 "
+then
+echo killing
+ rm -f /dev/mixer.old
+ mv /dev/mixer /dev/mixer.old 2>/dev/null
+ #if test -d /dev/snd
+ #then
+ #(cd /;tar cfj $OSSLIBDIR/save/alsadevs.tar.bz2 dev/snd)
+ #fi
+
+ #mv /dev/snd /dev/snd.osssave
+ #fuser -k -s /dev/mixer.old /dev/snd.osssave/*
+fi
+
+# Remove all loaded ALSA modules
+SOUNDDEVS=
+
+if test -f /dev/mixer.old
+then
+ SOUNDDEVS="$SOUNDDEVS /dev/mixer.old"
+fi
+
+if test -d /dev/snd.osssave
+then
+ SOUNDDEVS="$SOUNDDEVS /dev/snd.osssave/*"
+fi
+
+for timeout in 0 1 2 3 4 5 6 7 8 9 10 11
+do
+ if test "`cat /proc/modules|grep ^snd_|sed 's/ .*//'` " = " "
+ then
+ break
+ fi
+
+ if test $timeout -gt 10
+ then
+ echo Cannot unload the ALSA modules. Apparently there is some
+ echo application keeping them busy.
+ echo Please reboot your system and try to start OSS again.
+ ps ax
+ lsmod
+ cat /proc/devices
+ cat /proc/interrupts
+ exit 1
+ fi
+
+ if test "$SOUNDDEVS " != " "
+ then
+ fuser -s -9 $SOUNDDEVS
+ else
+ echo Cannot find any processes using the conflicting sound driver
+ fi
+
+ for n in `cat /proc/modules|grep ^snd_|sed 's/ .*//'`
+ do
+ rmmod $n
+ #rmmod $n >/dev/null 2>&1
+ done
+
+ sleep 1
+done
+
+rmmod snd > /dev/null 2>&1
+
+# Remove soundcore
+rmmod soundcore > /dev/null 2>&1
+
+rm -f /dev/mixer.old
+
+if cat /proc/devices|grep -q '^ *14 '
+then
+
+ echo There still appears to be another sound driver hanging around
+
+ lsmod
+ cat /proc/devices|grep '^ *14 '
+ cat /proc/interrupts
+
+ exit 1
+fi
+
+for n in /dev/sndstat /dev/mixer* /dev/dsp* /dev/midi* /dev/sequencer /dev/music
+do
+ if readlink $n >/dev/null 2>&1
+ then # Symbolic link
+ if readlink $n | grep -q asound
+ then # Link to ALSA devices
+ rm -f $n
+ fi
+ fi
+done
+
+# Disable automatic startup of ALSA during system bootup
+
+if test "`ls /etc/rc.d/rc*/*alsasound*` " != " " > /dev/null 2>&1
+then
+ (cd /;tar cfj $OSSLIBDIR/save/alsarc/tar.bz2 etc/rc.d/rc*/*alsasound*)
+ rm -f /etc/rc.d/rc*/*alsasound*
+fi > /dev/null 2>&1
+
+exit 0
diff --git a/setup/Linux/oss/scripts/restore_drv.sh b/setup/Linux/oss/scripts/restore_drv.sh
new file mode 100644
index 0000000..9046d04
--- /dev/null
+++ b/setup/Linux/oss/scripts/restore_drv.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+if test -f /etc/oss.conf
+then
+ . /etc/oss.conf
+else
+ OSSLIBDIR=/usr/lib/oss
+fi
+
+/usr/sbin/soundoff
+
+rm -rf /lib/modules/`uname -r`/kernel/oss
+
+if test -x /sbin/chkconfig
+then /sbin/chkconfig oss off > /dev/null 2>&1
+else
+ if test -x /sbin/update-rc.d
+ then /usr/sbin/update-rc.d -f oss remove > /dev/null 2>&1
+ fi
+fi
+
+rm -f /etc/init.d/oss
+
+if ! test -d /lib/modules/`uname -r`/kernel/sound
+then
+ if test -f /lib/modules/`uname -r`/sound-preoss.tar.bz2
+ then
+ (cd /lib/modules/`uname -r`; tar xfj sound-preoss.tar.bz2)
+ /sbin/depmod -a
+ fi
+fi
+
+rm -f /lib/modules/`uname -r`/sound-preoss.tar.bz2
+
+if test -f $OSSLIBDIR/sysfiles.list
+then
+ rm -f `cat $OSSLIBDIR/sysfiles.list`
+fi
+
+if test -f $OSSLIBDIR/save/alsadevs.tar.bz2
+then
+ (cd /;tar xfj $OSSLIBDIR/save/alsadevs.tar.bz2)
+fi
+
+if test -f $OSSLIBDIR/save/alsarc/tar.bz2
+then
+ (cd /;tar xfj $OSSLIBDIR/save/alsarc/tar.bz2)
+fi
+
+rm -f /dev/dsp* /dev/midi* /dev/mixer* /dev/sndstat
+
+/sbin/ldconfig
+
+if test -x /sbin/chkconfig
+then
+ /sbin/chkconfig alsasound on > /dev/null 2>&1
+else
+ if test -x /usr/sbin/update-rc.d
+ then
+ /usr/sbin/update-rc.d alsa-utils defaults > /dev/null 2>&1
+ fi
+fi
+
+exit 0
diff --git a/setup/Linux/oss/scripts/setup-alsa.sh b/setup/Linux/oss/scripts/setup-alsa.sh
new file mode 100644
index 0000000..fdcf4ff
--- /dev/null
+++ b/setup/Linux/oss/scripts/setup-alsa.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# This script will restgore selected ALSA modules that were earlier removed by
+# remove_drv.sh
+
+if test -d /proc/asound
+then
+# ALSA is already loaded
+ exit 0
+fi
+
+if ! test -f /lib/modules/`uname -r`/sound-preoss.tar.bz2
+then
+ echo ALSA backup archive /lib/modules/`uname -r`/sound-preoss.tar.bz2 not found. Cannot continue.
+ exit 1
+fi
+
+RESTORE=kernel/sound/soundcore.ko
+
+for n in snd snd-pcm snd-timer snd-page-alloc
+do
+ RESTORE="$RESTORE kernel/sound/core/$n.ko kernel/sound/acore/$n.ko"
+done
+
+(cd /lib/modules/`uname -r` && tar xvfj sound-preoss.tar.bz2 $RESTORE)
+
+if test -d /dev/snd.save && ! test -d /dev/snd
+then
+ mv /dev/snd.save /dev/snd
+fi
+
+exit 0
diff --git a/setup/Linux/oss/scripts/showprocs.sh b/setup/Linux/oss/scripts/showprocs.sh
new file mode 100755
index 0000000..827bb33
--- /dev/null
+++ b/setup/Linux/oss/scripts/showprocs.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+PROCS="`fuser /dev/mixer* /dev/dsp* /dev/audio* /dev/sequencer /dev/music /dev/midi*|sed 's/.* //'|sort|uniq`"
+
+if test "$PROCS " = " "
+then
+ exit 0
+fi
+
+if test "$1 " != "-q "
+then
+echo $PROCS
+echo
+echo "NOTICE!"
+echo "======="
+echo
+echo There are some programs still using OSS devices. You may need to stop them
+echo manually:
+echo
+fi
+
+for pid in $PROCS
+do
+ ps ax|grep "^ *$pid "
+done
+
+echo
+
+exit 0