#!/bin/sh

if [ `uname -r` = "5.1-RELEASE" ] ; then
exit 0
fi

inc_refcount () {
grep -q hint\.sk\.refcount /boot/device.hints
if [ $? != 0 ] ; then
cp /boot/device.hints /boot/device.hints.orig
echo "hint.sk.refcount=\"1\"" >> /boot/device.hints
return
fi

ref_count=`cat /boot/device.hints | awk -F \" '/hint.sk.refcount/{print $2}'`
let inc_ref_count=$ref_count+1 >> /dev/null
cat /boot/device.hints | sed -e "s/hint.sk.refcount=\"$ref_count\"/hint.sk.refcount=\"$inc_ref_count\"/" > /boot/new.device.hints
mv /boot/new.device.hints /boot/device.hints
}

if [ $2 != "POST-INSTALL" ] ; then
exit
fi

inc_refcount

/usr/bin/nm /boot/kernel/kernel | /usr/bin/grep sk_devs > /dev/null
if [ $? = 1 ] ; then

exit
fi

cd /boot/kernel
cp kernel kernel.sk
./dlgepatchkernel
mv newkernel kernel
chmod 555 kernel
