: ${OK=0} ${FAIL=1} ${STOP=10}
VER=`uname -r`
HD_SPACE=/etc/conf/pack.d/hd/space.c
LINKPKG=/etc/perms/inst
Wd_Sdevice=/etc/conf/sdevice.d/wd
Wd0_Sdevice=/etc/conf/sdevice.d/wd0
Wd1_Sdevice=/etc/conf/sdevice.d/wd1
Tmp_Wd=/tmp/tmpwd
Tmp_Wd0=/tmp/tmpwd0
Tmp_Wd1=/tmp/tmpwd1
CONF=/etc/conf/cf.d
PRODUCT="VIA/VESA IDE Device Driver"
# Check whether the linkpkg exists.
linkpkg_check()
{
if [ ! -f $LINKPKG ] ; then
echo "Please install the LINK PACKAGE first.\n"
exit $FAIL
fi
}
#Mask Default IDE Card
mask_default_ide()
{
grep Y $Wd_Sdevice > /dev/null 2>&1
if [ $? -eq 0 ] ; then
sed "s/Y/N/" $Wd_Sdevice > $Tmp_Wd || {
echo "Enable to modify the $Wd_Sdevice\n"
return $FAIL
}
fi
grep Y $Wd0_Sdevice > /dev/null 2>&1
if [ $? -eq 0 ] ; then
sed "s/Y/N/" $Wd0_Sdevice > $Tmp_Wd0 || {
echo "Enable to modify the $Wd0_Sdevice\n"
return $FAIL
}
fi
grep Y $Wd1_Sdevice > /dev/null 2>&1
if [ $? -eq 0 ] ; then
sed "s/Y/N/" $Wd1_Sdevice > $Tmp_Wd1 || {
echo "Enable to modify the $Wd1_Sdevice\n"
return $FAIL
}
fi
trap_off
mv $Tmp_Wd $Wd_Sdevice > /dev/null 2>&1
mv $Tmp_Wd0 $Wd0_Sdevice > /dev/null 2>&1
mv $Tmp_Wd1 $Wd1_Sdevice > /dev/null 2>&1
trap_on
return $OK
}
# Add the routine entry to the "/etc/conf/pack.d/hd/space.c"
add_hd_space_c()
{
ed $HD_SPACE > /dev/null 2>&1 <<EOF
/wd0
a
extern int vth0pres(), vth0open(), vth0intr(), vth0halt();
.
/wd0
a
{vth0pres, vth0open, vth0intr, vth0halt, 1},
.
w
EOF
}
#Rebuild the kernel.
build_kernel()
{
cd $CONF
getyn "You must create and install a new kernel
to complete the $PRODUCT installation.
Do you wish to create a new kernel now" || {
getyn "The $PRODUCT software will not function until a
new kernel is re-linked and installed.
Do you wish to create a new kernel now" || {
exit $OK
}
}
echo "\nRe-linking the kernel ..." >&2
../bin/idbuild -y || {
echo "kernel link failed."
exit $FAIL
}
echo "
The system must be re-booted for the installation to be complete
Press <Return> to continue\c"
read x
}
# Turn on the trap.
trap_on() {
trap 'echo "\nThe installation is Interrupted! Exiting ! "; cleanup 1' 1 2 3 15
}
# Turn off the trap.
trap_off() {
trap '' 1 2 3 15
}
# Remove temp files and exit with the status passed as argument
cleanup() {
trap_off
rm -f $Tmp_Wd $Tmp_Wd0 $Tmp_Wd1 > /dev/null 2>&1
exit $1
}
# Get the Yes or No answer.
getyn()
{
while echo "\n$* (y/n)? \c">&2
do read yn rest
case $yn in
[yY]) return 0 ;;
[nN]) return 1 ;;
*) echo "Please answer y or n" >&2 ;;
esac
done
}
# Main
if [ "$VER" = "3.2" ]
then
linkpkg_check
cd /tmp/ID/vth
/etc/conf/bin/idcheck -p vth ; exit_code=$?
if [ $exit_code -lt 16 ] ; then
mkdir /etc/conf/pack.d/vth
/etc/conf/bin/idinstall -a -e -k -m -s -o -p -t vth
else
/etc/conf/bin/idinstall -u -e -k -m -s -o -p -t vth
fi
cd /tmp/ID/vth0
/etc/conf/bin/idcheck -p vth0 ; exit_code=$?
if [ $exit_code -lt 16 ] ; then
mkdir /etc/conf/pack.d/vth0
/etc/conf/bin/idinstall -a -e -k -m -s -o -p -t vth0
else
/etc/conf/bin/idinstall -u -e -k -m -s -o -p -t vth0
fi
cd /tmp/ID/vth1
/etc/conf/bin/idcheck -p vth1 ; exit_code=$?
if [ $exit_code -lt 16 ] ; then
mkdir /etc/conf/pack.d/vth1
/etc/conf/bin/idinstall -a -e -k -m -s -o -p -t vth1
else
/etc/conf/bin/idinstall -u -e -k -m -s -o -p -t vth1
fi
echo "Disable default IDE driver !"
mask_default_ide
echo "Disable default IDE driver successfully !\n"
echo "Change the IDE configuration file."
add_hd_space_c
echo "Change the IDE configuration file successfully !\n "
build_kernel
else
echo "This device driver must be installed on the SCO UNIX upper"
echo "\"3.2\" version.\n"
exit
fi