yorn ()
{
        YN=b
        while [ "$YN" != "n" -a "$YN" != "no" -a \
                "$YN" != "N" -a "$YN" != "NO" -a \
                "$YN" != "y" -a "$YN" != "yes" -a \
                "$YN" != "Y" -a "$YN" != "YES" -a \
                "$YN" != "Yes" -a "$YN" != "No" ]; do
                echo $1
                read YN
                if [ "$YN" = "y" -o "$YN" = "yes" -o "$YN" = "Yes" -o \
                     "$YN" = "Y" -o "$YN" = "YES" ]; then
                        return 1
                fi
                if [ "$YN" = "n" -o "$YN" = "no" -o "$YN" = "No" -o \
                     "$YN" = "N" -o "$YN" = "NO" ]; then
                        return 0
                fi
                echo "Please enter y or n"
        done
}

cont ()
{
        yorn "Do you wish to continue (y/n): \c"
        res=$?
        if [ "$res" != "1" ]; then
                exit 0
        fi
}

SCCSid="@(#) websync-install 1.0"

umask 000

if [ ".$COBDIR" = "." ]; then
	echo "COBDIR must be set to point to a valid product."
	echo exiting...
	exit 1
fi

if test ! -w /etc/passwd
then
        echo "You must be root to run this script"
        exit 1
fi

CHECKSTR=22.02
grep "$CHECKSTR$" $COBDIR/etc/cobver >/dev/null
rc=$?
if [ $rc != 0 ]
then
        echo "This update can only be applied to the $CHECKSTR product"
        echo exiting...
        exit 1
fi

/usr/sbin/slibclean

echo WARNING: This will update your product with websync update Fixpack22.02_11
cont

if [ -f "$COBDIR/bin/editor" ]; then
cd cobol
else
cd apps 
fi

grep '^PTI=Fixpack22.02_11$' $COBDIR/etc/cobver > /dev/null 2>&1
if [ $? -eq 0 ]
then
  echo "Your product has already been updated with Websync update Fixpack22.02_11."
  echo "Installation aborted."
  exit 1
fi

rm -f /tmp/Fixpack22.02_11.err
tar cf - . |(cd $COBDIR ; tar xf - || touch /tmp/Fixpack22.02_11.err)
if test -f /tmp/Fixpack22.02_11.err
then
  echo "*** Installation of Fixpack22.02_11 failed"
  echo "    Please ensure that you have exclusive access to the product in"
  echo "    $COBDIR and try again"
  exit 1
fi

cd $COBDIR/etc
cp cobver /tmp/cobver.$$
grep -v '^PTI=$' /tmp/cobver.$$ >cobver
cat >>cobver <<EOF
PTI=Fixpack22.02_11
EOF
rm /tmp/cobver.$$

echo Installation of websync update Fixpack22.02_11 complete.

