home *** CD-ROM | disk | FTP | other *** search
- #!/bin/csh -f
- # Installation script for MAEstro demos.
- # Copyright (C) 1994 by George D. Drapeau
- #
-
- set OsRelease = `uname -r` # What release of the operating system is this?
- switch ($OsRelease)
- case "4.*": # SunOS 4.X
- set RootDir = /cdrom/MAEstro # Set top-level directory from which to retrieve MAEstro demos
- breaksw
- case "5.*": # SunOS 5.X
- set RootDir = /cdrom/unnamed_cdrom/MAEstro # Set top-level directory from which to retrieve MAEstro demos
- breaksw
- default: # Probably not any SunOS
- set RootDir = /cdrom/MAEstro # Set top-level directory from which to retrieve MAEstro demos
- breaksw
- endsw
-
-
- set DestDir = "/usr/local/MAEstro" # Set up a default directory for the MAEstro demos
-
- set MAEstroDemoDir = "$RootDir/Demos" # Determine where to find the correct MAEstro applications
- set MAEstroDemoString = "/cdrom/MAEstro/Demos" # Set up string to use when renaming paths for demo documents
-
- if (!(-e $MAEstroDemoDir)) then
- echo "Cannot find the directory $RootDir. Please make sure"
- echo "that you have mounted the CD-ROM as /cdrom, then try"
- echo "this installation script again."
- exit (-1)
- endif
-
- set DiskSpaceNeeded = `du -s $MAEstroDemoDir | awk '{print $1}'`# Determine disk space needed to install the MAEstro demos
-
- echo ""
- echo "The default installation directory is "
- echo " $DestDir"
- echo ""
- echo "MAEstro demos require $DiskSpaceNeeded KB of disk space."
- echo ""
- echo "Would you like to install MAEstro demos into "
- echo -n "'$DestDir'? [y/n] "
- set DestDir_ok = $< # Ask the installer if the default directory is okay.
-
-
- CustomInstallDirectory: # Here begins code to install demos in a custom directory
-
- if ($DestDir_ok != y) then # The default directory is not okay, prompt for a new place
- echo ""
- echo "Where would you like to install MAEstro demos? "
- echo "(type 'q' to quit the installation process now.)"
- echo -n "--> "
- set DestDir = $<
- endif
-
- if ($DestDir == "q") then # Did the installer choose to exit without installing the demos?
- echo "MAEstro demos were not installed."
- exit (-1) # Yes, honor that choice and quit right now
- endif
-
- if (!(-e $DestDir)) then # Does the specified directory exist?
- echo ""
- echo "The directory '$DestDir' does not exist."
- echo -n "Would you like to create it? [y/n] " # No, shall this program create such a directory?
- set create = $<
- if ($create == y) then # Yes, try to create the directory specified by the installer
- echo -n "Creating installation directory..."
- mkdir $DestDir >& /dev/null # Create the directory and set appropriate permissions
- if ($status != 0) then
- echo ""
- echo "Could not create the directory $DestDir."
- echo "Please try another directory name."
- echo ""
- goto CustomInstallDirectory
- endif
- chmod 0755 $DestDir
- echo "Done."
- else
- echo "Please try again:"
- echo ""
- goto CustomInstallDirectory
- endif
- else
- echo ""
- endif
-
- #
- # Avoid problems with long df entries...
- #
- set DF_LONG = `df $DestDir | tail -1 | awk '{print $4}' | egrep % | wc -c`
- if ( $DF_LONG == "0" ) then
- set FreeDiskSpace = `df $DestDir | tail -1 | awk '{print $4}'`
- else
- set FreeDiskSpace = `df $DestDir | tail -1 | awk '{print $3}'`
- endif
-
- if ($FreeDiskSpace < $DiskSpaceNeeded) then # Is there enough space to hold the MAEstro demos?
- echo "Sorry, MAEstro demos require $DiskSpaceNeeded KB of free disk space" # No, inform the installer
- echo "but there are only $FreeDiskSpace KB free in '$DestDir'."
- echo "Please free up disk space or install MAEstro demos"
- echo "in a different directory, then run this installation script again."
- exit (-1) # Exit this script without doing any installation
- endif
-
-
- echo ""
- echo -n "Installing MAEstro demo content material into '$DestDir'..."
-
- cp -r $MAEstroDemoDir/* $DestDir # Copy the MAEstro demos into the desired directory
-
- echo "Done."
-
- cd $DestDir # Go to the installed Demos directory to repair files
-
- foreach i (Demo*) # Look at each demo directory, doing the following:
- pushd $DestDir/$i >& /dev/null # Go to that demo directory
- echo -n "Installing Demo '$i'..."
- foreach fileName (*) # Look at each file in the directory
- grep $MAEstroDemoString $fileName >& /dev/null
- set result = $status
- if ($result == 0) then # Is there something to replace?
- cat $fileName | \
- sed "s@$MAEstroDemoString@$DestDir@" > $fileName.New # Yes, set the path of the document to that of the...
- rm -f $fileName # ...directory where the demo is installed.
- mv $fileName.New $fileName # Delete old file and replace it with new file
- endif
- end
- echo "Done."
- popd >& /dev/null
- end
-
-
- echo ""
- echo 'Installation was successful. Enjoy\!'
-
- exit (0) # Installation was successful; get outtahere.
-