#! /bin/sh
#
# Usage:        batch1.sh install_arguments
#		batch.boot install_arguments (boot time only)
#
# Abstract:     This Bourne Shell script performs a normal
#		(type 1) type of installation in batch.
#
# Options:
#		install_arguments - arguments simply passed on without
#				    parsing to install_matlab.
#
# Note(s):	1. Supply values for the right hand side for the
#		   following variables in this script. See the
#		   README in the MATLAB ./install directory for further
#		   explanation.
#
#		   WATCH OUT!
#
#		   If the MATLAB root directory is part of an AUTOMOUNTED
#		   directory supply a directory path for MATLAB that does
#		   not include any mount point information. It must be a
#		   path that forces a mount to be done if it is currently
#		   unmounted.
#
#		   MATLAB=
#		   OUTPUT_FILE=
#		   IS_SIMULINK_LICENSED=	yes OR no
#		   CHECK_SYMBOLIC_FOR_MAPLE= 	yes OR no
#			(supported platforms except alpha)
#		   MAPLE_LIBRARIES_DIR=
#			(contains 32-bit files:  maple.hlp, maple.ind,
#						 maple.lib)
#		   CHECK_SYMBOLIC_FOR_MAPLE64= 	yes OR no
#			(alpha only)
#		   MAPLE_LIBRARIES64_DIR=
#			(contains 64-bit files:  maple.hlp, maple.ind,
#						 maple.lib)
#		   SITE_ID=
#		   WANT_ACCESS_DIR=	 	yes OR no
#		   ACCESS_DIR=
#		   WANT_MAN_PAGES=	 	yes OR no
#		   MAN_PAGES_DIR=
#		   WANT_LICENSE_MANAGER=	yes OR no
#			(Ignored on convex and cray.)
#		   WANT_LMBOOT_LINK=		yes OR no 
#			(Ignored on convex and cray and lnx86.)
#
#		   NO BLANKS around the "=" in the assignments!
#		   Put strings with blanks in single quotes.
#
#		2. Run this script as root.
#
#               3. If this routine is sourced then the variable arglist
#                  contains any extra arguments to be passed to
#		   install_matlab. arglist should never be the empty
#		   string even when there are no arguments.
#
#		4. The trap must include deleting temporary files
#		   /tmp/$$b and /tmp/$$c for the CDROM case because
#		   the trap must mirror that in the backend since this
#		   routine is sourced by the backend.
#
# Example:	1. Here is a sample dataset
#
#		   MATLAB=/usr/local/matlab  
#		   OUTPUT_FILE=/usr/local/matlab/install1.out
#		   IS_SIMULINK_LICENSED=yes
#		   CHECK_SYMBOLIC_FOR_MAPLE=yes
#		   MAPLE_LIBRARIES_DIR=/usr/local/maple/lib
#		   CHECK_SYMBOLIC_FOR_MAPLE64=no
#		   MAPLE_LIBRARIES64_DIR=
#		   SITE_ID='LN 12372'
#		   WANT_ACCESS_DIR=yes
#		   ACCESS_DIR=/usr/local/bin
#		   WANT_MAN_PAGES=no
#		   MAN_PAGES_DIR=
#		   WANT_LICENSE_MANAGER=yes
#		   WANT_LMBOOT_LINK=no
#
# Copyright (c) 1992-95 by The MathWorks, Inc.
# $Revision: 1.20 $  $Date: 1995/11/13 13:52:27 $
#----------------------------------------------------------------------------
#+++++++++++++++ substitute right hand values as required ++++++++++++++++++
#
    MATLAB=
    OUTPUT_FILE=
    IS_SIMULINK_LICENSED=
    CHECK_SYMBOLIC_FOR_MAPLE=
    MAPLE_LIBRARIES_DIR=
    CHECK_SYMBOLIC_FOR_MAPLE64=
    MAPLE_LIBRARIES64_DIR=
    SITE_ID=''
    WANT_ACCESS_DIR=
    ACCESS_DIR=
    WANT_MAN_PAGES=
    MAN_PAGES_DIR=
    WANT_LICENSE_MANAGER=
#	(Ignored on convex and cray.)
    WANT_LMBOOT_LINK=
#	(Ignored on convex and cray and lnx86.)
#
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#    
    trap "rm -rf /tmp/$$a /tmp/$$b /tmp/$$c > /dev/null 2>&1; exit" 0 1 2 3 15
#
# Set batch in the environment for the bootstrap case
#
    batch=1; export batch
#
    DOLLAR_MATLAB='$MATLAB'
    if [ "$arglist" = "" ]; then
        cat > /tmp/$$a << EOF
#
# MATLAB installation: normal
#
MATLAB=$MATLAB
$DOLLAR_MATLAB/install_matlab $* -b 1 > $OUTPUT_FILE 2>&1 << EOF
$MATLAB
$IS_SIMULINK_LICENSED
EOF
    else
        cat > /tmp/$$a << EOF
#
# MATLAB installation: normal
#
MATLAB=$MATLAB
$DOLLAR_MATLAB/install_matlab $arglist -b 1 > $OUTPUT_FILE 2>&1 << EOF
$MATLAB
$IS_SIMULINK_LICENSED
EOF
    fi
#
    if [ `expr "//$CHECK_SYMBOLIC_FOR_MAPLE" : '//[Nn].*'` -gt 0 ]; then
        cat >> /tmp/$$a << EOF
$CHECK_SYMBOLIC_FOR_MAPLE
EOF
    else
        cat >> /tmp/$$a << EOF
$CHECK_SYMBOLIC_FOR_MAPLE
$MAPLE_LIBRARIES_DIR
EOF
    fi
#
    if [ `expr "//$CHECK_SYMBOLIC_FOR_MAPLE64" : '//[Nn].*'` -gt 0 ]; then
        cat >> /tmp/$$a << EOF
$CHECK_SYMBOLIC_FOR_MAPLE64
EOF
    else
        cat >> /tmp/$$a << EOF
$CHECK_SYMBOLIC_FOR_MAPLE64
$MAPLE_LIBRARIES64_DIR
EOF
    fi
#
    cat >> /tmp/$$a << EOF
$SITE_ID
EOF
    if [ `expr "//$WANT_ACCESS_DIR" : '//[Nn].*'` -gt 0 ]; then
        cat >> /tmp/$$a << EOF
$WANT_ACCESS_DIR
EOF
    else
        cat >> /tmp/$$a << EOF
$WANT_ACCESS_DIR
$ACCESS_DIR
EOF
    fi
#
    if [ `expr "//$WANT_MAN_PAGES" : '//[Nn].*'` -gt 0 ]; then
        cat >> /tmp/$$a << EOF
$WANT_MAN_PAGES
EOF
    else
        cat >> /tmp/$$a << EOF
$WANT_MAN_PAGES
$MAN_PAGES_DIR
EOF
    fi
#
    cat >> /tmp/$$a << EOF
$WANT_LICENSE_MANAGER
EOF
    if [ `expr "//$WANT_LICENSE_MANAGER" : '//[Nn].*'` -gt 0 ]; then
	:
    else
        cat >> /tmp/$$a << EOF
$WANT_LMBOOT_LINK
EOF
    fi
    cat >> /tmp/$$a << EOF2
EOF
EOF2
#
    . /tmp/$$a
