#!/usr/local/bin/bash
###############################################################################
# We need the bash for defining an array for the partitions and devices!
# So never ever change the first line!
###############################################################################

# static definitions
HD1=c1t0d0
HD2=c1t1d0

# what are our disk devices
DEV1="../../devices/`awk '/0 \"ssd\"/ {print $1}' /etc/path_to_inst | sed 's/\"//g'`"
DEV2="../../devices/`awk '/1 \"ssd\"/ {print $1}' /etc/path_to_inst | sed 's/\"//g'`"

# Where is the backup root mount pointing to?
DEVROOT="/mnt/backuproot/dev"

# Define an array for our partitions we need to create the links to
declare -a part

part[0]=a
part[1]=b
part[2]=c
part[3]=d
part[4]=e
part[5]=f
part[6]=g
part[7]=h

# first go to our block devices (filesystems)
# remove all the old links
cd $DEVROOT/dsk
rm c1t?d0*

# Start creating the new links
for i in 0 1 2 3 4 5 6 7
do
	 ln -s ${DEV2}:${part[${i}]} ${HD1}s${i}
	 ln -s ${DEV1}:${part[${i}]} ${HD2}s${i}
done

# next go to the character devices (rawdisks)
# remove all the old links
cd $DEVROOT/rdsk
rm c1t?d0*

# Start creating the new links
for i in 0 1 2 3 4 5 6 7
do
	 ln -s ${DEV2}:${part[${i}]},raw ${HD1}s${i}
	 ln -s ${DEV1}:${part[${i}]},raw ${HD2}s${i}
done

# make the backup boot disk bootable (just in case)
/usr/sbin/installboot /usr/platform/sun4u/lib/fs/ufs/bootblk ${DEVROOT}/rdsk/${HD2}s0

