# Copyright 1995 Massachusetts Institute of Technology.  All Rights 
# Reserved.
# 
# You are hereby granted a worldwide, irrevocable, paid-up, right and 
# license to use, execute, display, modify, copy and distribute MIT's 
# Modifications, provided that (i) you abide by the terms and conditions 
# of your Transarc AFS License Agreement, and (ii) you do not use the name 
# of MIT in any advertising or publicity without the prior written consent 
# of MIT.  MIT disclaims all liability for your use of MIT's 
# Modifications.  MIT's Modifications are provided "AS IS" WITHOUT 
# WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, 
# ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR 
# NONINFRINGEMENT.
# 
# 

vers=`uname -r`
echo "AFS Detected kernel version $vers"

if [ `grep -c smp_invalidate_needed /proc/ksyms` = 1 ]; then
    echo "AFS Detected SMP Kernel"
    module=libafs.smp.$vers.o
else
    module=libafs.$vers.o
fi

if [ -d /usr/vice/etc/dkload ]; then
        echo 'Invoking dynamic kernel loader...'
        cd /usr/vice/etc/dkload
        if [ -f $module ]; then
		PATH=.:/sbin:$PATH; export PATH
                echo "Loading AFS module $module"
		insmod -f -m -o libafs $module 2> /dev/console | sort > /var/tmp/zModule.map
		if [ $? != 0 ]; then
		   echo "Error loading AFS"
		   exit 1
		fi
	else
		echo "Cannot load AFS - no kernel module $module"
 		exit 1
	fi
        cd /
fi
exit 0
