#!/bin/sh
N=`basename $0`
uname -r | grep '3.2' > /dev/null
if [ "$?" != "0" ]
then
echo "$N: This only applies to SVR3!"
exit 1
fi
id | grep 'uid=0' > /dev/null
if [ "$?" != "0" ]
then
echo "$N: Must be run as root!"
exit 1
fi
PACK=/etc/conf/pack.d/kernel
BKUP=${PACK}/.xfree86
if [ ! -d ${BKUP} ]
then
echo "$N: Backup directory ${BKUP} does not exist!"
exit 1
fi
OWD=${PWD}
cd ${BKUP}
./patcher -c ../os.o
if [ "$?" != "0" ]
then
echo "$N: Patch not applied. Aborting"
cd ${OWD}
exit 1
fi
LOC=`./patcher -u ../os.o ./Nos.o`
if [ "$?" != "0" ]
then
echo "$N: Patch removal failed!!!"
cd ${OWD}
exit 1
fi
LOC1=`cmp -l ../os.o ./Nos.o | awk '{print $1; exit}'`
if [ "$LOC" != "$LOC1" ]
then
echo "$N: Patch sanity check failed!!!"
cd ${OWD}
exit 1
fi
echo "$N: Patch successfully removed. Installing unpatched module."
mv ./Nos.o ../os.o
echo "$N: Building the new kernel."
/etc/conf/bin/idbuild 2>/tmp/idb.$$
if [ "$?" != "0" ]
then
echo "$N: Kernel build failed! Errors are in /tmp/idb.$$"
cd ${OWD}
exit 1
fi
rm -f /tmp/idb.$$
echo "$N: Kernel successfully rebuilt."
cd ${OWD}
rm -fr ${BKUP}
REBOOT=0
echo "$N: You must reboot before patch takes effect. Reboot now? \c"
read RESP
case ${RESP} in
[yY]*)
REBOOT=1
;;
*)
echo "$N: OK. But remember to reboot later"
;;
esac
cd ${OWD}
rm -fr ${BKUP}
if [ ${REBOOT} = "1" ]
then
cd /
sync
/etc/shutdown -i6 -g15 -y &
fi
exit 0