#!/bin/sh
# @(#)wabidirupdate	1.3	16 Jun 1995
#
#	wabidirsetup:	Sets up WABIDIR
#
#	Copyright (c) 1991-95, Sun Microsystems, Inc.  All Rights Reserved
#	Sun considers its source code as an unpublished, proprietary
#	trade secret, and it is available only under strict licens
#	provisions.  This copyright notice is placed here only to protect
#	Sun in the event the source is deemed a published work.  Dissassembly,
#	decompilation, or other means of reducing the object code to human
#	readable form is prohibited by the license agreement under which
#	this code is provided to the user or company in possession of this
#	copy.
# 
#	RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the
#	Government is subject to restrictions as set forth in subparagraph
#	(c)(1)(ii) of the Rights in Technical Data and Computer Software
#	clause at DFARS 52.227-7013 and in similar clauses in the FAR and
#	NASA FAR Supplement.



    # commdlz.dll and shellz.dll are moved to $WABIDIR/windows/system
    $RM "$WABIDIR/windows/commdlz.dll"
    $RM "$WABIDIR/windows/shellz.dll"
    $RM "$WABIDIR/windows/system/tt3219z_.ttf"
    $RM "$WABIDIR/windows/system/tt3219z_.fot"

    # Copy autoexec.bat file to $WABIDIR
    if [ ! -f "$WABIDIR/autoexec.bat" ]
    then
        cp "$WABIHOME/wbin/autoexec.bat" "$WABIDIR"
    fi


    # Copy config.sys file to $WABIDIR
    if [ ! -f "$WABIDIR/config.sys" ]
    then
        cp "$WABIHOME/wbin/config.sys" "$WABIDIR"
    fi


    # Copy win.ini to $WABIDIR/windows
    if [ ! -f "$WABIDIR/windows/win.ini" ]
    then
    	cp "$WABIHOME/wbin/win.ini" "$WABIDIR/windows"
    else
	if [ "$MERGE" = "yes" ]  
	then
	    mv "$WABIDIR/windows/win.ini" "$WABIDIR/windows/win.ini.$WABIVERSION"
	    $WABIMERGEFILE -P "$WABIDIR/windows/win.ini.$WABIVERSION" "$WABIHOME/wbin/win.ini" "$WABIDIR/windows/win.ini"
	    echo "Saving existing win.ini to win.ini.$WABIVERSION and updating win.ini."

            # the following SED command deletes any line containing (case-
	    # insensitive) any of the following system font files:
	    # 	8514oem.fon, 8514sys.fon, 8514fix.fon,
	    #   vgaoem.fon, vgasys.fon, vgafix.fon
            # within the set of lines that start with the line starting with
            # (case-insensitive) "[font]" and ending (inclusive) with the next
            # line starting with "[".

	    sed '/^\[[Ff][Oo][Nn][Tt][Ss]\]/,/^\[/{
/8514[Oo][Ee][Mm]\.[Ff][Oo][Nn]/d
/8514[Ff][Ii][Xx]\.[Ff][Oo][Nn]/d
/8514[Ss][Yy][Ss]\.[Ff][Oo][Nn]/d
/[Vv][Gg][Aa][Oo][Ee][Mm]\.[Ff][Oo][Nn]/d
/[Vv][Gg][Aa][Ff][Ii][Xx]\.[Ff][Oo][Nn]/d
/[Vv][Gg][Aa][Ss][Yy][Ss]\.[Ff][Oo][Nn]/d
}' "$WABIDIR/windows/win.ini" > "$WABIDIR/windows/win.tmp" 
	    $RM "$WABIDIR/windows/win.ini"
	    mv "$WABIDIR/windows/win.tmp" "$WABIDIR/windows/win.ini"	

        fi
    fi

    # if upgrading a wabidir with Windows already installed, update control.inf
    # with data from oemsetup.ini

    if [ "$MERGE" = "yes" ]
    then
        if [ -n "$__WABI_MSWIN_VER" ]
        then
            mv "$WABIDIR/windows/system/control.inf" "$WABIDIR/windows/system/control.inf.$WABIVERSION"
            $WABIMERGEFILE -N "$WABIHOME/printers/oemsetup.ini" "$WABIDIR/windows/system/control.inf.$WABIVERSION" "$WABIDIR/windows/system/control.inf"
            echo "Saving existing control.inf to control.inf.$WABIVERSION and updating control.inf."
            mv "$WABIDIR/windows/control.ini" "$WABIDIR/windows/control.ini.$WABIVERSION"
            $WABIMERGEFILE -P "$WABIHOME/wbin/control.ini" "$WABIDIR/windows/control.ini.$WABIVERSION" "$WABIDIR/windows/control.ini"
            echo "Saving existing control.ini to control.ini.$WABIVERSION and updating control.ini."
        fi
    fi


#   In the case of an upgrade from 1.X to 2.0, we should not move
#   in our version of reg.dat over the user's.

    # Copy wabi.grp source file to the windows directory.
    if [ ! -f "$WABIDIR/windows/wabi.grp" ]
    then
        cp "$WABIHOME/wbin/wg_new.lst" "$WABIDIR/wabi_grp.tmp"
    else
	if [ "$MERGE" = "yes" ]
	then
	    cp "$WABIHOME/wbin/wg_20_21.lst" "$WABIDIR/wabi_grp.tmp"	  
	fi
    fi


    # Link dosprmpt.pif to $WABIHOME/wbin to start a PC/DOS Emulator session when called.
    if [ ! -f "$WABIDIR/windows/dosprmpt.pif" ]
    then
        $LN "../wabihome/wbin/dosprmpt.pif" "$WABIDIR/windows/dosprmpt.pif"
    fi


    # Link pwi.dll to WABIHOME/wbin.
    if [ ! -f "$WABIDIR/windows/pwi.dll" ]
    then
        $LN "../wabihome/wbin/pwi.dll" "$WABIDIR/windows/pwi.dll"
    fi


    # Copy share.exe file to the windows directory
    if [ ! -f "$WABIDIR/windows/share.exe" ]
    then
        cp "$WABIHOME/wbin/share.exe" "$WABIDIR/windows/share.exe"
    fi


    # Create win_inst.exe symbolic link to win_inst.exe
    if [ ! -f "$WABIDIR/windows/win_inst.exe" ]
    then
        $LN "../wabihome/wbin/win_inst.exe" "$WABIDIR/windows/win_inst.exe"
    fi

   
    # Create regiwabi.exe symbolic link to regiwabi.exe
    if [ "$SYSTEM_OS_NAME" = "SunOS" ]
    then
    	if [ ! -f "$WABIDIR/windows/regiwabi.exe" ]
    	then
            $LN "../wabihome/wbin/regiwabi.exe" "$WABIDIR/windows/regiwabi.exe"
    	fi
    fi


    # Create the windows/system directory if necessary.
    if [ ! -d "$WABIDIR/windows/system" ]
    then 
        mkdir "$WABIDIR/windows/system" 
    fi

    
    # Link wabisync.dll file to the windows/system directory.
    if [ ! -f "$WABIDIR/windows/system/wabisync.dll" ]
    then
        $LN "../../wabihome/wbin/wabisync.dll" "$WABIDIR/windows/system"
    fi

    # Link cplcfg.cpl file to the windows/system directory.
    if [ ! -f "$WABIDIR/windows/system/cplcfg.cpl" ]
    then
        $LN "../../wabihome/wbin/cplcfg.cpl" "$WABIDIR/windows/system/cplcfg.cpl"
    fi
  
    # Link Epson printer driver file to the windows/system directory.
    if [ ! -f "$WABIDIR/windows/system/wbiepson.drv" ]
    then 
	$LN "../../wabihome/printers/wbiepson.drv" "$WABIDIR/windows/system/wbiepson.drv"
    fi


    # Link Epson printer help file to the windows/system directory.
    if [ ! -f "$WABIDIR/windows/system/wbiepson.hlp" ]
    then 
	$LN "../../wabihome/printers/wbiepson.hlp" "$WABIDIR/windows/system/wbiepson.hlp"
    fi

    
    # Link PCL printer driver file to the windows/system directory.
    if [ ! -f "$WABIDIR/windows/system/whppcl5a.drv" ]
    then 
	$LN "../../wabihome/printers/whppcl5a.drv" "$WABIDIR/windows/system/whppcl5a.drv"
    fi


    # Link PCL printer help file to the windows/system directory.
    if [ ! -f "$WABIDIR/windows/system/whppcl5a.hlp" ]
    then 
	$LN "../../wabihome/printers/whppcl5a.hlp" "$WABIDIR/windows/system/whppcl5a.hlp"
    fi


    # Link PCL option DB help file to the windows/system directory.
    if [ ! -f "$WABIDIR/windows/system/whppcl5o.hlp" ]
    then 
	$LN "../../wabihome/printers/whppcl5o.hlp" "$WABIDIR/windows/system/whppcl5o.hlp"
    fi


    # Copy  file timer.drv to the windows/system directory.
    if [ ! -f "$WABIDIR/windows/system/timer.drv" ]
    then 
	cp "$WABIHOME/wbin/timer.drv" "$WABIDIR/windows/system/timer.drv"
    fi


    # Link toolhelp.dll file to the windows/system directory.
    if [ ! -f "$WABIDIR/windows/system/toolhelp.dll" ]
    then
    	cp "$WABIHOME/wbin/toolhelp.dll" "$WABIDIR/windows/system/toolhelp.dll"
    fi


    # Link chlmss.fon file to the windows/system directory.
    if [ ! -f "$WABIDIR/windows/system/chlmss.fon" ]
    then
        $LN "../../wabihome/wbin/chlmss.fon" "$WABIDIR/windows/system/chlmss.fon"
    fi


    # Copy user.exe file to the windows/system directory.
    if [ ! -f "$WABIDIR/windows/system/user.exe" ]
    then
        cp "$WABIHOME/wbin/user.exe" "$WABIDIR/windows/system/user.exe"
    fi


    # Link copybits.94 file to the windows/system directory.
    if [ ! -f $WABIDIR/windows/system/copybits.94 ]
    then
        $LN "../../wabihome/wbin/copybits.94" "$WABIDIR/windows/system/copybits.94"
    fi

