#!/bin/sh
#
# aryzhov@spasu.net
# Re-allocate controller ID's 0 and 1 to the bus
# that have disk target 6
#
[ -z "$SID" ] && SID=/tmp/install_config
[ X$SubrIsRead = XYes ] || . $SID/Scripts/Misc/!Includes/Subroutines
[ X$VarsAreSet = XYes ] || SetJVars

echo | format  -e

cd /dev/cfg || StartShell === No /dev/cfg ===
C0=`find /devices | grep /sd@6, |                sed 's:/sd@.*$::' | sort | uniq -c | sort -rn | head -1 | awk '{print $2}'`
C1=`find /devices | grep /sd@6, | grep -v $C0/ | sed 's:/sd@.*$::' | sort | uniq -c | sort -rn | head -1 | awk '{print $2}'`
CX=`ls -l | grep $C0: | awk '{print $(NF-2)}'`
CY=`ls -l | grep $C1: | awk '{print $(NF-2)}'`
[ x$CX = x ] && StartShell === CX undefined ===
[ x$CY = x ] && StartShell === CY undefined ===
mv c0 cX && mv $CX c0 && mv cX $CX
mv c1 cY && mv $CY c1 && mv cY $CY
rm /dev/*dsk/c*
devlinks

echo ===========================

echo | format  -e

