/
Cool3/bin/
#!/bin/csh

# Set srcpath equal to your "src" dir.
# Set back equal to your backup dir.
# Use and enjoy.  :)

set srcpath = ./
set back = ~/back

if ( -e "$srcpath/Mkbk_s" ) then
    ;
else
    cp ./Mkbk_s $srcpath/Mkbk_s
endif

cd $srcpath
if ( "$1" == "" ) then
    echo Syntax: Mkbk_s "<"directory">"
    exit 1
endif
if ( -e "$1" ) then
    echo Error: Target directory already exists!
    exit 1
else
    echo Creating directory...
    mkdir "$1"
    echo Copying files.........
    if ( -e "Makefile" ) then
	cp Makefile "$1"
    else
	echo Error: Makefile not found.
	exit 1
    endif
    if ( -e "act_comm.c" ) then
	cp *.c "$1"
    else
	echo Error: Sample .c file not found.
	exit 1
    endif
    if ( -e "merc.h" ) then
	cp *.h "$1"
    else
	echo Error: Sample .h file not found.
	exit 1
    endif

    # Since Mkbk_s can be separate, we don't error if Mkback isn't there.

    if ( -e "Mkback" ) then
	cp Mkback "$1"
    if ( -e "Mkbk_s" ) then
	cp Mkbk_s "$1"
    else
	echo Error: Mkbk_s "("this file")" not found.
	exit 1
    endif
    cd "$1"
    echo Beginning TAR file creation process....
    tar -cWf "$1".tar *
    echo Beginning GZ file creation process..........
    gzip -9 "$1".tar
    echo Removing temporary files...
    rm *.c
    rm *.h
    rm Makefile
    rm Mkback
    rm Mkbk_s
    set newtargz = $back/"$1".tar.gz
    if ( -e $newtargz ) then
	echo File already exists in $back.
	echo Please manually move "$1".tar.gz to your backup dir.
    else
	mv "$1".tar.gz $back
	cd ../
	rmdir "$1"
	echo Backup file process complete.
    endif
    chmod 600 "$newtargz"
endif

if ( "$2" != "Mkback_main" ) then
echo Mkback ""src"" dir submodule:
echo copyright "("c")" 1998 Daniel Reif, dan@betterbox.net
endif