#!/bin/sh
# xCAT postscript to configure GPFS on a stateless node.
# Before booting nodes with this postscript, gpfs must be up and configured correctly on the node
# pointed to by the -p flag below.  The $MASTER environment variable will be set by xCAT to
# the service node or management node of this booting node.  If you want the nodes to get their
# GPFS configuration from a different node, replace $MASTER with that IP address.

# The source server:location of the mmsdrfs file.  Default is this xCAT MN.
#SOURCE=gpfsmgr:/var/mmfs/gen/mmsdrfs
SOURCE=/var/mmfs/gen/mmsdrfs

# The gpfsmgr which save the mmsdrfs file.  generally it is XCATMASTER
GPFSMGR=$MASTER

if [[ ! -z "$installroot" ]]; then
  OS=`uname`
  if [[ "$OS" != "AIX" ]]; then
    rsync -i -t $SOURCE $installroot/var/mmfs/gen/mmsdrfs
    if [[ $? != 0 ]]
    then
        echo "Error: rsync -i -t $SOURCE $installroot/var/mmfs/gen/mmsdrfs failed.  Please make sure GPFS is configured correctly!"
    else
        echo "rsync -i -t $SOURCE $installroot/var/mmfs/gen/mmsdrfs succeed"
    fi
    exit
  fi
else
  echo "Restoring GPFS configration file from server."
  /usr/lpp/mmfs/bin/mmsdrrestore -p $GPFSMGR -R /usr/bin/scp &
fi
