#!/bin/sh

# This script was written by Wayne Piekarski - wayne@cs.unisa.edu.au

VER=`uname -r`
echo
echo "---- Restart 1394 Script $VER ----"

echo "Current modules are ..."
lsmod | grep 1394

echo "Removing modules ..."
rmmod raw1394
rmmod video1394
rmmod ohci1394
rmmod ieee1394

echo "Restarting modules ..."
MOD=/lib/modules/$VER/kernel/drivers/ieee1394
insmod $MOD/ieee1394.o

# Install the ohci module, this could cause a problem
insmod $MOD/ohci1394.o attempt_root=1 &> /dev/null
if [ ! "$?" = "0" ]; then
	# We have a newer kernel which doesn't support attempt_root
	echo "Module ohci1394.o failed to load so retrying with no attempt_root"
	insmod $MOD/ohci1394.o

	if [ ! "$?" = "0" ]; then
		echo "Cannot load module ohci1394.o due to a fatal error!"
		beep
		exit 1
	fi
fi

# Load the rest of the modules in now
insmod $MOD/video1394.o
insmod $MOD/raw1394.o

echo
echo "Success! Module list is now ..."
lsmod | grep 1394

echo "Waiting 1 second for 1394 bus to settle ..."
sleep 1s

echo "---- Ending 1394 Script ----"
echo

