#! /bin/sh
#	Tutorial Setup Script for Saber-C 2.1
#	Copyright (C) 1989 by Saber Software, Inc.

# This parameter is set by the installation procedure.
SABER_DIR=NotInstalledCorrectly

# Don't depend on user's PATH.
PATH=/bin:/usr/bin:/usr/ucb

echo ""
echo "          Saber-C Tutorial Setup Program"
echo ""

if [ ! -d $SABER_DIR -o ! -d $SABER_DIR/common -o ! -d $SABER_DIR/common/tutorial ]; then
	if [ ! -d $SABER_DIR ]; then
		>&2 echo \
"saber_tutorial: error: directory '$SABER_DIR'
does not exist.  It should be the directory that contains Saber-C
binaries and support files.  Your system administrator should reinstall
Saber-C, being careful to specify a universal path that is good on all
clients of the file server."
	else
		>&2 echo \
"saber_tutorial: directory '$SABER_DIR' exists
but is not set up correctly.  (It should contain 'common' and
'common/tutorial', but it doesn't.)  Your system administrator should
install the 'common' directory."
	fi
	exit 2
fi

if [ -d saber_tutorial_dir ]
then
	echo "Directory 'saber_tutorial_dir' exists ...not creating"
else
	echo "Creating directory: saber_tutorial_dir"
	mkdir saber_tutorial_dir

	if [ $? != 0 ]
	then
		echo "Could not create directory: saber_tutorial_dir"
		exit 2
	fi
fi

D=$SABER_DIR/common

echo "Copying tutorial files into 'saber_tutorial_dir'."

cp $D/tutorial/Makefile saber_tutorial_dir
chmod ugo+w saber_tutorial_dir/Makefile

cp $D/tutorial/sort.h saber_tutorial_dir
chmod ugo+w saber_tutorial_dir/sort.h

cp $D/tutorial/main.c saber_tutorial_dir
chmod ugo+w saber_tutorial_dir/main.c

cp $D/tutorial/sort.c saber_tutorial_dir
chmod ugo+w saber_tutorial_dir/sort.c

cp $D/tutorial/display.c saber_tutorial_dir
chmod ugo+w saber_tutorial_dir/display.c

cp $D/tutorial/list.c saber_tutorial_dir
chmod ugo+w saber_tutorial_dir/list.c

cp $D/tutorial/Tutorial saber_tutorial_dir
chmod ugo+w saber_tutorial_dir/Tutorial

echo ""

echo "Listing of files:"
ls saber_tutorial_dir
