An action script has the following arguments: an input file, HA_INFILE, an output file HA_OUTFILE, and an optional parameter file HA_PARAMFILE. These become the positional arguments to the script, $1, $2 and $3 parameter file is optional.
The ha_check_args() function checks the arguments specified for a script and sets the $HA_INFILE and $HA_OUTFILE variables accordingly.
If a parameter file exists, the ha_check_args() function reads the list of parameters from the file and sets the $HA_CLUSTERNAME variable.
In the following, long lines use the continuation character (\) for readability.
ha_check_args()
{
${HA_DBGLOG} "$HA_SCRIPTNAME called with $1, $2 and $3"
if ! [ $# -eq 2 -o $# -eq 3 ]; then
${HA_LOG} "Incorrect number of arguments"
return 1;
fi
if [ ! -r $1 ]; then
${HA_LOG} "file $1 is not readable or does not exist"
return 1;
fi
if [ ! -s $1 ]; then
${HA_LOG} "file $1 is empty"
return 1;
fi
if [ $# -eq 3 ]; then
HA_PARAMFILE=$3
if [ ! -r $3 ]; then
${HA_LOG} "file $3 is not readable or does not exist"
return 1;
fi
HA_CLUSTERNAME=`/usr/bin/awk '{ if ( $1 == "ClusterName" ) \
print $2 }' ${HA_PARAMFILE}`
fi
HA_INFILE=$1
HA_OUTFILE=$2
return 0;
} |