#!/bin/csh
# Copy user's default files to a safe place so they
# won't get overwritten
#put into setup clean

#Check for correct usage

if ($1 == "") then
	echo "Usage: $0 <test name>" >&
	exit 1
endif


#Move user's own defaults to temporary files
#so they won't be wiped out

if ($1 == "clean") then
	echo "moving default files..."
	mv  $HOME/.Xdefaults $HOME/Xdefaults.tst
	mv  $HOME/.mwmrc $HOME/mwmrc.tst
	mv  $HOME/.x11start $HOME/x11start.tst
	mv  $HOME/.xinitrc $HOME/xinitrc.tst
	echo "Copying Instructions to HOME directory"
	cp ./Instructions $HOME/Instructions
	exit 0
endif


#Move user's own defaults back so that
#their environment is restored

if ($1 == "restore") then
	echo "restoring default files..."
	mv  $HOME/Xdefaults.tst $HOME/.Xdefaults
	chmod 644 $HOME/.Xdefaults
	mv  $HOME/mwmrc.tst $HOME/.mwmrc
	chmod 744 $HOME/.mwmrc
	mv  $HOME/x11start.tst $HOME/.x11start
	chmod 744 $HOME/.x11start
	mv  $HOME/xinitrc.tst $HOME/.xinitrc
	chmod 744 $HOME/.xinitrc
	echo "removing Instructions from HOME directory"
	rm $HOME/Instructions
	exit 0
endif


#Copy default files from test directory into
#user's home directory

cp ./xdefaults/$1 $HOME/.Xdefaults
chmod 777 $HOME/.Xdefaults
echo "Copying ./xdefaults/$1 to $HOME/.Xdefaults"
if ($1 == "test3") then
	cp ./mwmrc/$1 $HOME/.myconfig
	chmod 777 $HOME/.myconfig
	echo "Copying ./mwmrc/$1 $HOME/.myconfig"
else
	cp ./mwmrc/$1 $HOME/.mwmrc
	chmod 777 $HOME/.mwmrc
	echo "Copying ./mwmrc/$1 to $HOME/.mwmrc"
endif
cp ./x11start/$1 $HOME/.x11start
chmod 777 $HOME/.x11start
echo "Copying ./x11start/$1 to $HOME/.x11start"
cp ./xinitrc/$1 $HOME/.xinitrc
chmod 777 $HOME/.xinitrc
echo "Copying ./xinitrc/$1 to $HOME/.xinitrc"
cp ./instruct/$1 $HOME/.instruct
chmod 777 $HOME/.instruct
echo "Copying ./instruct/$1 to $HOME/.instruct"
