#!/bin/ksh
################################################################################
#    iGMT: Interactive Mapping of Geoscientific Datasets.                      #
#               Easy access to GMT via a Tcl/Tk GUI                            #
#                                                                              #
#    Copyright (C) 1998  Thorsten W. Becker, Alexander Braun                   #
#                                                                              #
#    This program is free software; you can redistribute it and/or modify      #
#    it under the terms of the GNU General Public License as published by      #
#    the Free Software Foundation; either version 2 of the License, or         #
#    (at your option) any later version.                                       #
#                                                                              #
#    This program is distributed in the hope that it will be useful,           #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of            #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             #
#    GNU General Public License for more details.                              #
#                                                                              #
#                                                                              #
#    You should have received a copy of the GNU General Public License         #
#    along with this program; see the file COPYING.  If not, write to          #
#    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,          #
#    Boston, MA 02111-1307, USA.                                               #
#                                                                              #
################################################################################


# handle .gmtdefault affairs at startup and shut down time
# has to be cleaned up and commented



# these are the parameters 
    
opmode1=$1
rootdirectory=$2
opmode2=$3
gmtversion=$4


cwd=`pwd`

if [ $opmode1 -eq 1 ]
then
    if [ -s $cwd/.gmtdefaults ]
    then 
	nr=`diff $cwd/.gmtdefaults $rootdirectory/igmt_gmtdefaults_$gmtversion | wc -l`
	if [ $nr -gt 0 ]
	then 
	    cp $cwd/.gmtdefaults $cwd/TEMPORARILY_MOVED_GMT_DEFAULT
	    cp $rootdirectory/igmt_gmtdefaults_$gmtversion $cwd/.gmtdefaults
	    echo "moved"
	else
	    echo "0"
	fi
    else
	cp $rootdirectory/igmt_gmtdefaults_$gmtversion $cwd/.gmtdefaults
	echo "oum"
    fi
fi
if [ $opmode1 -eq 2 ]
then 
    if [ -s $cwd/TEMPORARILY_MOVED_GMT_DEFAULT ] 
    then 
	mv $cwd/TEMPORARILY_MOVED_GMT_DEFAULT $cwd/.gmtdefaults
    fi
    if [ $opmode2 -eq 1 ]
    then
	if [ -a $cwd/.gmtdefaults ]
	then
	   rm $cwd/.gmtdefaults 
	fi
    fi
fi


