GIS.sh updated again

Markus Neteler neteler at geog.uni-hannover.de
Fri Jan 29 09:19:27 EST 1999


Sorry, this is the correct file:

You can also get it from GRASS 4.2.1 server -> GRASS FAQ.


Markus

----- cut here -------------------------------------
: ${GISBASE?}

# get home directory, name of lockfile and gisrc file

home=`cd;pwd`
lockfile=$home/.gislock
GISRC=$home/.grassrc
export GISRC

# set the GIS_LOCK variable to current process id

GIS_LOCK=$$
export GIS_LOCK

# set PATH to GRASS bin, ETC to GRASS etc

ETC=$GISBASE/etc
PATH=$GISBASE/bin:$GISBASE/scripts:$GISBASE/garden/bin:$PATH
export PATH

# check for concurrent use

$ETC/lock $lockfile $$
case $? in
 0) ;;
 1)
    echo `whoami` is currently running GRASS. Concurrent use not allowed.
    exit ;;
 *)
    echo Unable to properly access $lockfile
    echo Please notify system personel.
    exit ;;
esac

# first time user ...

if [ ! -f $GISRC ]
then
	cat $ETC/gis_intro
	echo ""
	echo "Hit RETURN to continue"
	read ans
fi

# user selects LOCATION and MAPSET

$ETC/gis_set
case $? in
 0) ;;
 *) exit ;;
esac

# unset the MONITOR variable to force user to select one if they are going
# to do graphics.

g.gisenv MONITOR=

# get gisrc into the environment

eval `g.gisenv`

LOCATION=${GISDBASE?}/${LOCATION_NAME?}/${MAPSET?}
export LOCATION

if [ -x $home/.grassrc.4.2.1 ]
then
	$home/.grassrc.4.2.1
elif [ -x $GISBASE/grassrc ]
then
	$GISBASE/grassrc
fi
##############################################################

trap "" 2 3

sh="`basename $SHELL`"
case "$sh" in
    ksh)  shellname="Korn Shell";;
    csh)  shellname="C Shell" ;;
    tcsh) shellname="TC Shell" ;;
    bash) shellname="Bash Shell" ;;
    sh)   shellname="Bourne Shell";;
    *)    shellname=shell;;
esac

# Display the advertising
clear
cat << EOF
Welcome to GRASS 4.2.1 (V.20 - December 1998) 

Geographic Resources Analysis Support System (GRASS) is a Trademark
of U.S. Army Construction Engineering Research Laboratories (USACERL)
and Baylor University GRASS Research Group.

This new release of GRASS is coordinated and produced by the GRASS
Research Group at Baylor University with assistance from the Office
of GRASS Integration (OGI) located at USACERL.


This version running thru the $shellname ($SHELL)
Help is available with the command: g.help
When ready to quit enter:           exit
EOF

case "$sh" in

csh|tcsh)
    HOME=$LOCATION
    export HOME
    cshrc=$HOME/.cshrc
    tcshrc=$HOME/.tcshrc
    rm -f $cshrc $tcshrc
    echo "set home = $home" > $cshrc
    echo "set history = 30 noclobber ignoreeof" >> $cshrc

    echo "set prompt = '\\" >> $cshrc
    echo "Mapset <${MAPSET}> in Location <${LOCATION_NAME}> \\" >> $cshrc
    echo "GRASS 4.2.1 > '" >> $cshrc
    echo 'set BOGUS=``;unset BOGUS' >> $cshrc

    if [ -r $home/.grass.cshrc ]
    then
	cat $home/.grass.cshrc >> $cshrc
    fi

    if [ -r $home/.cshrc ]
    then
	grep '^ *set  *mail *= *' $home/.cshrc >> $cshrc
    fi

    if [ -r $home/.tcshrc ]
    then
	grep '^ *set  *mail *= *' $home/.tcshrc >> $cshrc
    fi

    if [ -r $home/.login ]
    then
	grep '^ *set  *mail *= *' $home/.login >> $cshrc
    fi

    echo "set path = ( $PATH ) " | sed 's/:/ /'g >> $cshrc

    cp $cshrc $tcshrc
    $ETC/run $SHELL

    HOME=$home
    export HOME
    ;;

bash)
    USERHOME=$home      # save original home
    HOME=$LOCATION      # save .bashrc in $LOCATION
    export HOME
    bashrc=$HOME/.bashrc
    rm -f $bashrc
    echo "test -z $PROFILEREAD && . /etc/profile" > $bashrc
    echo "test -e ~/.alias && . ~/.alias" >> $bashrc
    echo "umask 022" >> $bashrc

    if [ -r $home/.grass.bashrc ]
    then
	cat $home/.grass.bashrc >> $bashrc
    fi

    echo "export PATH=$PATH" >> $bashrc
    echo "export HOME=$USERHOME" >> $bashrc # restore user home path
    echo "export DISPLAY=:0.0"  >> $bashrc  # set to localhost

    $ETC/run $SHELL
    HOME=$USERHOME
    export HOME
    ;;

*)

PS1="
Mapset <$MAPSET> in Location <$LOCATION_NAME>
GRASS-GRID > "

    export PS1

    $ETC/run $SHELL
    ;;
esac

trap 2 3
#############################################################
# unset the MONITOR variable

monitor=`g.gisenv MONITOR`
if [ "$monitor" ]
then
	$ETC/mon.release -v $monitor
fi
g.gisenv MONITOR=

# Read gisrc again

eval `g.gisenv`
LOCATION=${GISDBASE?}/${LOCATION_NAME?}/${MAPSET?}


# exit session. remove unwanted files

clear
echo ""
echo "GRASS SESSION WRAPUP"
echo ""

echo "You have just finished working on mapset: <$MAPSET>"
echo ""

any=no
dir=$LOCATION/cell
type=RASTER
count=0
if [ -d $dir ]
then
    count=`ls $dir | wc -l`
fi
if [ $count != 0 ]
then
    any=yes
    echo ""
    echo "The following $type maps belong to it:"
    ls -C $dir | awk '{print " " $0}'
    echo ""
else
    echo "There are no $type maps in this mapset"
fi

dir=$LOCATION/dig
type=VECTOR
count=0
if [ -d $dir ]
then
    count=`ls $dir | wc -l`
fi
if [ $count != 0 ]
then
    any=yes
    echo ""
    echo "The following $type maps belong to it:"
    ls -C $dir | awk '{print " " $0}'
    echo ""
else
    echo "There are no $type maps in this mapset"
fi

dir=$LOCATION/site_lists
type=SITES
count=0
if [ -d $dir ]
then
    count=`ls $dir | wc -l`
fi
if [ $count != 0 ]
then
    any=yes
    echo ""
    echo "The following $type maps belong to it:"
    ls -C $dir | awk '{print " " $0}'
    echo ""
else
    echo "There are no $type maps in this mapset"
fi

echo ""
if [ $MAPSET != PERMANENT ]
then
    $GISBASE/etc/echo -n "Shall the mapset <$MAPSET> be saved? y/n [y]"
    read ans
else
    ans=YES
fi

case $ans in
    n|no|N|NO|No)
	echo ""
	echo "WARNING - if you remove your mapset, you will lose"
	echo "          all your data files in this mapset"
	echo ""
	$GISBASE/etc/echo -n "are you sure you want to remove your mapset? y/n [n]"
	read ans
	case $ans in
	    y|yes|Y|YES|Yes)
		echo ""
		echo "Removing MAPSET $MAPSET"
		rm -rf $LOCATION
		if [ -d $LOCATION ]
		then
		    echo "WARNING: Unable to completely remove $LOCATION"
		else
		    echo "MAPSET --$MAPSET-- REMOVED."
		fi
		sleep 3 ;;
	    *) ;;
	    esac
	    ;;

    *)
	if [ $any = yes ]
	then
	    echo ""
	    $GISBASE/etc/echo -n "Do you wish to selectively remove data files? y/n [n]"
	    read ans
	    case $ans in
		y|yes|Y|YES|Yes) 
		    $GISBASE/bin/g.remove  ;;
		*) ;;
	    esac
	fi
	($ETC/clean_temp > /dev/null &)
esac
clear
echo ""
echo ""
echo ""
echo "                  GOOD BYE from GRASS"
rm -f $lockfile
echo ""
echo ""



More information about the grass-user mailing list