#!/sbin/sh -x
#
# Andrei.Ryjov  AKA  aryzhov@spasu.net Thu Oct 26 09:47:43 MET DST 2000
#
# Start VxVM from net-booted diskless client and import volumes
# Can be used as copy-paste template in broken roovol recovery
#

mkdir /tmp/vx
cd /etc/vx.static && find . -print | cpio -cdump /tmp/vx

[ -d /var/vxvm/tempdb ]    || mkdir -p /var/vxvm/tempdb         || exit 1
[ -d /dev/vx/dsk/rootdg  ] || mkdir -p /dev/vx/dsk/rootdg       || exit 1
[ -d /dev/vx/rdsk/rootdg ] || mkdir -p /dev/vx/rdsk/rootdg      || exit 1

rm -f /etc/vx/reconfig.d/state.d/install-db

vxiod set 10
# vxconfigd -k -x cleartempdir -m disable
vxconfigd -k -m disable
vxdctl init
vxdctl initdmp

#
# 3 lines related to the date reset may need to be uncommented
# if that license key is expired
#
# DATE=`date '+%m%d%H%M%y'`
#date 0901020100
[ -r $SI_CONFIG_DIR/Scripts/Misc/VxLicenses ] && $SI_CONFIG_DIR/Scripts/Misc/VxLicenses

VxLicenses >&- 2>&-
echo === Switching vxconfigd to enable mode ===
vxdctl enable

# date $DATE

vxprint | grep '^v  rootvol' | grep ACTIVE | grep DISABLED && {

  MAJ=`grep '^vxio ' /etc/name_to_major | awk '{printf $2}'`

  for V in `vxprint -g rootdg -v -F '%{name}'`
  do
     [ -r /dev/vx/dsk/rootdg/$V  ] || mknod /dev/vx/dsk/rootdg/$V  b $MAJ `vxprint -g rootdg -v -F '%{minor}' $V`
     [ -r /dev/vx/rdsk/rootdg/$V ] || mknod /dev/vx/rdsk/rootdg/$V c $MAJ `vxprint -g rootdg -v -F '%{minor}' $V`
     vxvol start $V
  done

}


