#!/sbin/sh
#
# (C) Copyright Promise Technology, Inc., 1994
# This source file is the property of Promise Technology Inc.
# It may not be copied or distributed in any isomorphic form
# without an appropriate prior licensing arrangement with
# Promise Technology, Inc.
#
# Shell script to add disks
#
NOBRANDPRODUCTNAME="Caching Controller Driver V1.10"
PROMISEPRODUCTNAME="Promise UNIX Driver V1.10"
PRODUCTDATE=19930510
ADAPTERNAME="DC-200 "
THISPREFIX=P20
NODED=/etc/conf/node.d
MYNAME=hd
TMPFILE=/tmp/tmp$$
TMPFILE2=${TMPFILE}2
mymknode()
{
if [ $LDRIVE = 0 -o $LDRIVE = 1 ]
then
return
fi
TMPDIR=/tmp/ptinode$$
rm -r $TMPDIR > /dev/null 2>&1
mkdir $TMPDIR > /dev/null 2>&1
BASEMINOR=`expr ${LDRIVE} \* 16`
PNO=0
MINOR=0
/etc/conf/bin/idmknod -e ${TMPDIR} > /dev/null 2>&1
RVAL=$?
rm -r $TMPDIR > /dev/null 2>&1
if [ $RVAL != 0 ]
then
echo "Hard disk does not exist, please check it! Bye."
exit 1
fi
while [ $PNO != 16 ]
do
if [ $PNO != 7 -a $PNO != 8 -a $PNO != 9 -a $PNO != 14 -a $PNO != 15 ]
then
MINOR=`expr $BASEMINOR + $PNO`
echo "${MYNAME} rdsk/${LDRIVE}s${PNO} c ${MINOR}" >> ${NODED}/${MYNAME}
echo "${MYNAME} dsk/${LDRIVE}s${PNO} b ${MINOR}" >> ${NODED}/${MYNAME}
fi
PNO=`expr $PNO + 1`
done
/etc/conf/bin/idmknod > /dev/null 2>&1
rm ${NODED}/${MYNAME} > /dev/null 2>&1
#
# !!!! change group and mode for hard disk slices
#
chgrp sys /dev/rdsk/* /dev/dsk/* > /dev/null 2>&1
chmod 0600 /dev/rdsk/* /dev/dsk/* > /dev/null 2>&1
}
trap 'trap "" 1 2 3 9 15;
set +e;
cd /;
echo "You have cancelled the $CMD command. ";
rm -rf /var/spool/locks/.PTIADD.LOCK;
exit 2' 1 2 3 15
#
# START HERE
#
CMD=$0
echo "\n\nWhich controller will the hard disk be attached to?\n"
echo " 1. the primary or single controller"
echo " 2. the secondary controller"
echo "\nPlease choose answer(1 or 2)(default=1): \c"
read AAA
if [ "$AAA" = "2" ]
then
ADAPTER=1
else
ADAPTER=0
fi
echo "\n\nWhich cable (of this controller) will the hard disk be attached to?\n"
echo " 1. the first or single cable"
echo " 2. the second cable"
echo "\nPlease choose answer(1 or 2)(default=1): \c"
read AAA
if [ "$AAA" = "2" ]
then
CABLE=1
else
CABLE=0
fi
echo "\n\nWill the hard disk be the master(single) or slave drive on this cable?\n"
echo " 1. the master or single hard disk"
echo " 2. the slave hard disk"
echo "\nPlease choose answer(1 or 2)(default=2): \c"
read AAA
if [ "$AAA" = "1" ]
then
DRIVE=0
else
DRIVE=1
fi
LDRIVE=`expr $ADAPTER \* 4 + $CABLE \* 2 + $DRIVE`
#if [ -f /var/spool/locks/.PTIADD.LOCK ]
#then
# echo "Someone else is runnig the $0 command,"
# echo "and this command cannot be running concurrently."
# echo "So, please retry this command at a later time."
# exit 1
#else
# >/var/spool/locks/.PTIADD.LOCK
#fi
echo "\nThis command will destroy all the existing data on the hard disk."
echo "Do you wish to continue?(y/n)\c"
read ans
if [ "$ans" != "y" ] && [ "$ans" != "Y" ]
then
rm -rf /var/spool/locks/.PTIADD.LOCK
exit 0
fi
#
# !!!!!! DC400
#
ctrlnum=$ADAPTER
drivenum=`expr $CABLE \* 2 + $DRIVE`
ptigands g $ctrlnum $drivenum
echo "\n\nDo you want to change them(Y/N)? (default=Y) \c"
read AAA
if [ "$AAA" = "Y" -o "$AAA" = "y" -o "$AAA" = "" ]
then
while [ 1 ]
do
echo "\n CYLINDERS: \c"
read cyl
echo " HEADS : \c"
read head
echo " SECTORS : \c"
read sect
ptigands s $ctrlnum $drivenum $cyl $head $sect
if [ $? = 0 ]
then
echo "
sed -e '/adapter $ctrlnum drive $drivenum/s/^.*$/$cyl, $head, $sect, \/* adapter $ctrlnum drive $drivenum *\/ \/* DC400 *\//g' /etc/conf/pack.d/hd/space.c > $TMPFILE
mv $TMPFILE /etc/conf/pack.d/hd/space.c" > $TMPFILE2
chmod +x $TMPFILE2
$TMPFILE2
/etc/conf/bin/idbuild
break
fi
done
fi
#
# !!!!!! DC400
#
mymknode
harddisk=/dev/rdsk/${LDRIVE}s0
blkdev=dev/dsk/${LDRIVE}s
/etc/mount | grep ${blkdev} > /dev/null 2>&1
if [ $? = 0 ]
then
echo "Some file system in this disk has already been mounted,"
echo "so you cannot add this disk as a new one."
rm -rf /var/spool/locks/.PTIADD.LOCK
exit 1
fi
/sbin/fdisk $harddisk
if [ $? != 0 ]
then
echo "Cannot access $harddisk!"
rm -rf /var/spool/locks/.PTIADD.LOCK
exit 1
fi
echo "\nHard disk partitioning is complete."
sed '/\/$blkdev/d' /etc/vfstab >/etc/tmpvfstab
mv /etc/tmpvfstab /etc/vfstab
/sbin/disksetup -I $harddisk
if [ $? != 0 ]
then
echo "\nHard disk setup failed!"
rm -rf /var/spool/locks/.PTIADD.LOCK
exit 1
fi
rm -rf /var/spool/locks/.PTIADD.LOCK
exit 0