dirs 1.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#
# 
#
use strict;
use libinstall;
use installvars;

sub Install($$$)
{
    my ($server, $isupdate, $impotent) = @_;

    # Replace if this script does an update for ip/domain.
    return 0
	if ($isupdate);

Leigh Stoller's avatar
Leigh Stoller committed
16
    my @TESTBED_DIRS = ([$PREFIX, "0775"],["$PREFIX/etc", "0755"]);
17 18 19
    if ($server eq $OPS_SERVERNAME || $server eq $FS_SERVERNAME) {
	push(@TESTBED_DIRS, ([$USERROOT, "0755"],
			     [$PROJROOT, "0755"],
20
			     [$GROUPROOT, "0755"]));
21

22 23 24
	if ($SHAREDIR) {
	    push(@TESTBED_DIRS, [$SHAREROOT, "0755"]);
	}
25 26 27 28 29
	if ($SCRATCHDIR) {
	    push(@TESTBED_DIRS, [$SCRATCHROOT, "0755"]);
	}
    }

Leigh Stoller's avatar
Leigh Stoller committed
30 31 32 33 34
    Phase "etcdir", "Creating $PREFIX/etc", sub {
	DoneIfExists("$PREFIX/etc");
	mkdir "$PREFIX/etc",0755 or
	    PhaseFail("Unable to create $PREFIX/etc: $!");
    };
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    Phase "dirs", "Setting directory permissions", sub {
    	  foreach my $dirref (@TESTBED_DIRS) {
	      my ($dir, $newmode) = @$dirref;
	      Phase $dir, $dir, sub {
		  if (!-d $dir) {
		      PhaseFail("Directory $dir does not exist");
		  }
		  # Use the real path, to avoid symlink problems
		  my $realdir = `realpath $dir`;
		  chomp $realdir;
		  my ($mode,$group) = (stat($realdir))[2,5];
		  # Fix up the mode (strip file type)
		  $mode = $mode & 0777;
		  if ($mode == eval $newmode && $group eq getgrnam("tbadmin")) {
		      PhaseSkip("Already done");
		  }
		  ExecQuietFatal("$CHGRP tbadmin $realdir");
		  ExecQuietFatal("$CHMOD $newmode $realdir");
	      };
	  }
    };
    return 0;
}

# Local Variables:
# mode:perl
# End: