#!/bin/sh
# setup commands for first terminal session

# This script is a compromise. The potential problem comes in
# if a particular dot file doesn't exist. On most systems, there
# is no problem in having newuser create all possible dot files
# that a give shell might need we omit ksh for reasons I won't
# go into here. The problem I found was on a system where
# tcsh was the default, but the user was only given a .cshrc file.
# Normally that shouldn't be a problem. However on this particular
# system if you do have a .tcshrc file, you must also have a
# line like
#
# source /usr/local/etc/tcshrc
#
# in order for global settings to be read. Of course,
# newuser can't be expected to know that such a line
# is needed, so if you suddenly create a .tcshrc
# file with the BIRCH 'source' line in it, BIRCH
# will work, but the global tcshrc file won't be
# read. This is such a rare occurrence (I've only 
# ever seen it on one system) that my solution is
# to document it in the FAQ. 
#
# If you think about it, it is bad policy for the
# system administrator to require a specific line
# in each user's dot files to read the system-wide
# rc files. That's asking for trouble.

BIRCH=/home/psgendb
export BIRCH

cd

#.login file, used by C-shell family
FILELIST=".login"
SOURCEFILE='add_to_login'

# append contents of a source file to a 'dot' file.
# The source file calls BIRCH setup commands each
# time the user logs in or a new shell is started.
birchappend ()
{
for file in $FILELIST
do
    echo Setting up "$file" file
    if [ -f "$file" ]
       then
       chmod 700 "$file"
    fi
    cat $BIRCH/admin/$SOURCEFILE >> "$file"
    chmod 700 "$file"
done
}

birchappend


# C-shell family
FILELIST=".cshrc .tcshrc"
SOURCEFILE='add_to_cshrc'
birchappend

# Bourne-shell family
FILELIST=".profile .bash_profile .bash_login .bashrc .zshenv"
SOURCEFILE='add_to_profile'
birchappend


# Setup a .vnc directory for the user.
# Nothing is done unless there is a $BIRCH/local/admin/xstartup file.
$BIRCH/script/vncsetup

# Create desktop launchers for BIRCH
# Pending update by Dale
#python $BIRCH/script/makelauncher.py

echo Done!
echo Logout and login again so that the changes can take effect.
