#!/usr/bin/ksh
###################################################################
## Author: BRIAN HUNTER
## Email: brian@sutechy.com
## Date: 08/11/2024
## Script: mkdiskgroup.sh
## Description: Script to Interactively setup diskgroup in veritas
##################################################################
clear
#############################################################################
function AddDisk {
DISKGROUP=$1
cnt=0; disk=1
until [[ $TOTAL -eq '0' ]]
do
print "ACTION: vxdg -g $DISKGROUP disk0$disk=${MyArray[$cnt]}\n"
vxdg -g $DISKGROUP disk0$disk=${MyArray[$cnt]}
((TOTAL--))
((cnt++))
((disk++))
done
}
#############################################################################
## Run the vxdctl enable after attaching and configuring the new storage.
#############################################################################
vxdctl enable
typeset -a MyArray
i=0
for DEVICE in `vxdg list | grep -v 'DEVICE' | awk '{print $1}'`
do # print "$DEVICE\n"
vxdg list
print -n "INITIALIZE DEVICE [ $DEVICE ]: [y|n] "
read ans
if [[ $ans == [yY] ]]
then
print "ACTION: vxdisksetup -i $DEVICE format=sliced \n"
vxdisksetup -i $DEVICE format=sliced
MyArray[$i]=$DEVICE
((i = i + 1))
continue
else
print "OK: WE WILL NOT USE [ $DEVICE ]\n"
fi
done
print "MyArray: ${MyArray[*]}\n"
print "MyArray Total Elements: ${#MyArray[*]}\n"
TOTAL=${#MyArray[*]}
print -n "SHOULD WE USE [datadg] DISKGROUP?: [y|n] "
read diskdg
if [[ $diskdg == [yY] ]]
then
AddDisk datadg
else
print "OK: WE WILL NOT USE [$DEVICE]\n"
print -n "ENTER NAME OF DISK GROUP TO USE: "
read name
AddDisk $name
fi
exit 0