#!/bin/bsh
#
# IMPORTANT: READ ALL THE BELOW FIRST!!!
#
# Makes a cartridge ready for use on AIX (ie: run once per cartridge)
# Must run as root.
# You can usually ignore any errors that appear as long as the end result
# appears to work.
#
# Make sure the next free /dev/hdisk is hdisk1 or you might lose all the
# data on your existing hdisk1!!!  If you have an hdisk1 then change
# all instances of hdisk1 to hdiskX where X is whatever is the first
# unused drive number.
#
# If your drive is on a different SCSI bus or ID you'll have to change
# the appropriate lines below:
#	change the 4 in -w '4,0' to whatever your SCSI ID is
#	change the scsi0 to whatever your SCSI bus is (shouldn't have to)
#
# Change the /syquest mount point to whatever you want it to be.
#
# You have to make a unique cartridge number for each cartridge and
# make sure not to duplicate or forget them.
#
# The usage is "mksyquest <unique-cartridge-vg-number> z"
# The z is literal... just type in a "z".  It helps keep you from
# accidentally running mksyquest (instaed of msyquest) on an
# already mksyquest'd cartridge (and losing all the data!)

/usr/bin/mkdir /syquest

case "$1" in
"") echo "Usage: mksyquest <unique-cartridge-vg-number> <z>" 1>&2
    exit 1;
    ;;
esac

case "$2" in
'z') echo Making new syquest ;;
*)   echo "Usage: mksyquest <unique-cartridge-vg-number> z" 1>&2
     exit 1;
     ;;
esac

/usr/sbin/mkdev -c disk -t 'osdisk' -s 'scsi' -p 'scsi0' -w '4,0'
/bin/sleep 4
/usr/sbin/mkdev -c disk -t 'osdisk' -s 'scsi' -p 'scsi0' -w '4,0'

/usr/sbin/mkvg -f -y"syqvg$1" -s'1' '-n' hdisk1
/usr/sbin/mklv -y"syqlg$1" -t'jfslog' -u'1' "syqvg$1" 1 hdisk1
/usr/sbin/mklv -y"syqlv$1" -t'jfs' -u'1' -L'/syquest' "syqvg$1" 216 hdisk1

/usr/sbin/logform "/dev/syqlg$1"

echo now create the fs over the lv and mount it then chown and chmod /syquest
