#!/bin/sh

FILE=$1
ARCH=$2

DoHelp()
{
  clear
  echo "======================================================================="
  echo "Usage:    windu_regsetup {Registration File} {Architecture}"
  echo ""
  echo "Purpose:  Standardize registry file paths based on the location of "
  echo "          Wind/U's installation and automatically insert the registry"
  echo "          file into the into the system registry for the user."
  echo ""
  echo "Comments: Argument #1 is the name of the registry file (including file"
  echo "          extension) to be merged into the registry database."
  echo "          Argument #2 is the architecture that the registry file is to "
  echo "          be setup for, using the same syntax as building for a particular"
  echo "          architecture, i.e. sol2 and sol2-g"

  echo ""
  echo "Example:  windu_regsetup myfile.reg sol2"
  echo "======================================================================="
  
}

help="

******************************************************************************************************
This purpose of this script is to standardize regitry file paths based on the developer's WUHOME
and automatically insert the registry file into the system registry for the user.

This script requires two arguments in the correct order.  The first argument is
the name of the registry file to be setup including the extension.  The second argument
is the architecture that the registry file is to be setup for, using the same syntax as building
for a particular architecture, i.e. sol2 and sol2-g

Usage Example: $0 myfile.reg sol2"

if [ $# != 2 -o "$1" = "-help" -o "$1" = "-h" ]; then
  DoHelp
#	echo "$help"
	exit 1
fi

if  [ "${WUHOME}" = "" ]  # if the developer's WUHOME is not set it must be before proceeding
then
	echo "Your WUHOME is not set, please set it and try again!"

else	#in place of Arch and /export/home/windu in the ole registry files put the arch in
	#from the command line and the path from WUHOME and send it to a temp registry file

	sed -e s~Arch~$ARCH~g $FILE | sed -e s~.export.home.windu~$WUHOME~g > temp.reg
	regedit -nodisplay temp.reg
	#record the registry file into the ole registry using regedit
	rm temp.reg
fi

