access to PERMANENT (w/code)

Greg Koerper greg at towhee.cor2.epa.gov
Thu Aug 19 12:30:35 EDT 1993


 
> I am installing XGRASS4.1 (binary version) to be used of several user
> at our department. BUT, how can I give the other users access to the
> PERMANENT location (from the Global, Spearfish data sets).
> I have tried the access function in grass, and the chmod outside
> grass, but without any success. The other user can not get in contact
> with the existing data sets.
> --

I don't suggest that users share access to PERMANENT.   Instead, you can make
copies of the few (and small) files that a user needs as a local PERMANENT, and
then use soft UNIX links (ln -s) to provide read access to these databases.  I
have included a perl script that I have built for local use which builds a
GRASS database for a new user in dir grass_mapsets, adds 3 locations 
("us.albers", "us.latlong", "world.latlong") to which centralized, shared
mapsets are then soft linked (but note that the PERMANENT mapset is copied, not
linked--these PERMANENT files are bare bones and do not contain vector, site, or
raster data), and additionally builds the location spearfish.  For spearfish,
only 4 essential files are copied to a locally owned PERMANENT.  Then the 
original PERMANENT is linked to the spearfish LOCATION as the spearfish MAPSET.

This hack provides full access to shared data, both local databases and OGI
supplied (like spearfish), without the hassle of potential database corruption.
I'd welcome comments.

greg

******************************************************************************
Greg Koerper                            Internet: greg at heart.cor.epa.gov
ManTech Environmental Technology, Inc.  UUCP:     hplabs!hp-pcd!orstcs!koerper
US EPA Environmental Research Lab
200 SW 35th St., JSB                    
Corvallis, OR   97333     Rush Limbaugh plucks the heartstrings of America:  
(503) 754-4490                "I'm OK, because they're not!" 
 fax:  (503) 754-4338
******************************************************************************

#!/usr/local/bin/perl
# written to attach ERL-C GRASS Database to new GRASS user's database


#require "getopts.pl";

#&Getopts ('w');

$home = $ENV{'HOME'};
$dir = $opt_w ? "/dsk/heart2" : "/files/data/heart/data1";

#kludge
if (! -d $dir) {
    $dir = "/dsk/heart2";
	}
@locations = ("us.albers", "us.latlong", "world.latlong");

if (! -d "$home/grass_mapsets") {
	mkdir ("$home/grass_mapsets", 0755);
	}

chdir ("$home/grass_mapsets");
foreach $i (@locations) {
	if (! -d $i) {
		mkdir ($i, 0755);
		}
	chdir ($i);
	open (FILES, "ls $dir/grassdir/grass.data/$i |");
	@list = <FILES>;
	foreach $mapset (@list) {
		chop $mapset;
		next if $mapset =~ /^[a-z]/;
		next if $mapset =~ /README/;
		next if -d $mapset || -l $mapset;
		if ($mapset eq "PERMANENT") {
			system ("cp -r $dir/grassdir/grass.data/$i/$mapset $mapset");
			}
		else {
			system ("ln -s $dir/grassdir/grass.data/$i/$mapset $mapset");
			}
		}
	chdir ("$home/grass_mapsets");
	}

# also connect spearfish data
if (! -d "spearfish") {
	mkdir ("spearfish", 0755);
	}
chdir ("spearfish");
unless (-d "PERMANENT" || -l "PERMANENT") {
	mkdir ("PERMANENT", 0755);
	chdir ("PERMANENT");
	foreach $file ("DEFAULT_WIND", "MYNAME", "SEARCH_PATH", "WIND") {
		system "cp $dir/grassdir/home/data/spearfish/PERMANENT/$file $file";
		}
	chdir ("$home/grass_mapsets/spearfish");
	}

# (-d "spearfish" || -l "spearfish") ? print "yes\n" : print "no\n";
unless (-d "spearfish" || -l "spearfish") {
	system "ln -s $dir/grassdir/home/data/spearfish/PERMANENT spearfish";
	}
		

# write out a .grassrc4 file
open (GRASS, "> $home/.grassrc4");
print GRASS "GISDBASE: $home/grass_mapsets\n";
print GRASS "LOCATION_NAME: us.albers\n";
print GRASS "MAPSET: PERMANENT\n";
 



More information about the grass-user mailing list