#! /bin/csh -b
# CedarSetUp
# eduardo, February 9, 1990 3:27:24 pm PST
# ChJ, November 13, 1989 2:56:30 pm PST 
# wso, April 11, 1991 2:07:53 pm PDT
# JKF, May 29, 1991 4:30:05 pm PDT
# Nichols, May 10, 1990
# Welch, March 5, 1991
#
# setup for PARC conventions

set newuser = 0			# Configuring for brand new user?

while ($#argv >= 1)
    swtich ($argv[1])
	case -newuser:
	    shift argv
	    set newuser = 1
	    breaksw
	default
	    shift argv
	    echo "Ignoring command line argument $1
	    breaksw
    endsw
end

#set echo

# PARC specific
set cedar←dir = /project/cedar10.1/release

# Set environment for other Cedar scripts.
if ( `printenv cedar10.1` == "" ) setenv cedar10←1 /project/cedar10.1/release/

if ( ! -d $cedar10←1 ) then
	echo "cedar10←1 symbol/directory must exist"
	exit
endif

# Complain if user is not in magic Cedar protetion group.
groups | grep -s cedarguest
if ( $status ) then
	echo "You are not in the Unix protection group 'cedarguest'."
	echo "You should contact a system administrator to have yourself added."
endif

# Figure out which profiles, etc. to update.
echo "[Checking local files.]"

# Give the poor user a sample .login and .cshrc, if needed
set fresh←login = 0
foreach f ( .cshrc .login )
    if (! -e ~/$f) then
	echo "Installing new user $f"
	cp -p ${cedar←dir}/newaccount/$f ~
	if ($f == .login) set fresh←login = 1
    endif
end

set LocalFiles = ( .Xdefaults .xinitrc .twmrc .openwin-menu)

foreach f ($LocalFiles)
    set remoteFile=${cedar←dir}/X/$f
    if (! -e ~/$f ) then
	if ($newuser) then
	    # Don't plague the new user with questions
	    echo "Installing new user $f"
	    set NEWER = ""
	    cp -p $remoteFile/X/$f ~/$f
	else
	    set NEWER = yes
	    set msg="You do not have a copy of $f."
	endif
    else
        set NEWER = `find $remoteFile -newer ~/$f -print`
        set msg="Your copy of $f is older than the released version."
    endif
    if ( $NEWER != "" ) then
        echo $msg
        echo -n "Do you want a new copy of $f? "
        set YES = $<
        if ( $YES =~ y* ) then
            echo "[Updating $f.]"
            cp -p $remoteFile ~/$f
        endif
    endif
end

# Give final advice.
if ($newuser) then
    # Invoking script will give final advice
    echo "[CedarSetup for PARC done.]"
else if ($fresh←login) then

cat << //finalmessage//
[CedarSetUp for PARC done.]
You now have the default .login and .cshrc file for new accounts.
Log out and log in again so your UNIX environment is propery initialized.
You can then use "StartX" to start up the X window system, or
you can use "RawViewersWorld" to start up Cedar.
//finalmessage//

else

cat << //finalmessage//
[CedarSetUp for PARC done.]
Your .login file should be modified to do the following:
   1) setenv cedar10←1 /project/cedar10.1/release/
   2) Set your path to include
      /project/cedar10.1/bin
Adding the line
   source ${cedar←dir}/scripts/cedar.login
to your .login will do this.

After doing so, you should logout and login again.
//finalmessage//

endif
# eof