]> andersk Git - moira.git/blobdiff - incremental/afs_create.pl
added hosttable stuff
[moira.git] / incremental / afs_create.pl
index 7144fcb109a65cb393c68a37f10f97a1720861b6..16ae92da1b7c1d263df106624887df8265523fa1 100644 (file)
@@ -6,20 +6,6 @@ require "/moira/bin/afs_utils.pl";
 $protodir="/moira/dotfiles";
 $quota=1;
 
-%vtypes_ATHENA_MIT_EDU =
-    ("ACTIVITY", "activity",
-     "APROJ", "aproj",
-     "AREF", "aref",
-     "CONTRIB", "contrib",
-     "COURSE", "course",
-     "HOMEDIR", "user",
-     "PROJECT", "project",
-     "REF", "ref",
-     "SW", "sw",
-     "SYSTEM", "system",
-     "UROP", "urop",
-     );
-
 %proc =
     ("ATHENA.MIT.EDU", 'athena_proc' );
 
@@ -33,19 +19,23 @@ die "Usage: $0 locker type cell path user group\n" if (@ARGV != 6);
 $vtype = eval "\$vtypes_$c{$type}";
 die "Cannot create $type volumes in $cell\n" unless $vtype;
 $vname = $vtype . "." . $locker;
-
-# Find free space
-($asrv,$apart) = &afs_find($cell,$type,$quota);
-die "Unable to find space to create $vname in $cell\n" unless ($asrv&&$apart);
-
-# Create volume
-system("$vos create $asrv $apart $vname -cell $cell >/dev/null") &&
-    &fatal("Unable to create $vname in $cell");
+$vname =~ s/[^-A-Za-z0-9_.]//g;                # strip out illegal characters
+
+# Find free space/Create volume
+$tries = 0; $code = 1;
+while ($tries<3 && $code) {
+    ($asrv,$apart) = &afs_find($cell,$type,$quota,@except);
+    die "Unable to find space to create $vname in $cell\n" unless ($asrv&&$apart);
+    $code = system("$vos create $asrv $apart $vname -cell $cell >/dev/null");
+    push(@except, $asrv);
+    $tries++;
+}
+&fatal("Unable to create $vname in $cell") if ($code); # Too many create errors
 push(@clean, "$vos remove $asrv $apart $vname -cell $cell >/dev/null");
 
 # Create mountpoint and set quota
 $path =~ s:^/afs/([^.]):/afs/.\1:;
-system("$fs checkb >/dev/null; $fs mkm $path $vname");
+system("$fs checkv >/dev/null; $fs mkm $path $vname");
 &fatal("Unable to create $path") if ($?);
 push(@clean, "$fs rmm $path");
 
@@ -76,8 +66,10 @@ chop($_ = <FS>);
 close(FS);
 &fatal("Can't get information about $p") if ($?);
 @tmp = (split(/ /,$_));
-system("$vos release $tmp[$#tmp] -cell $cell >/dev/null") &&
-    &fatal("Can't release $tmp[$#tmp] in cell $cell");
+if ($tmp[$#tmp] !~ /user\../) {
+    system("$vos release $tmp[$#tmp] -cell $cell >/dev/null") &&
+       &fatal("Can't release $tmp[$#tmp] in cell $cell");
+}
 
 &afs_quota_adj($cell,$asrv,$apart,$quota);
 exit(0);
@@ -106,6 +98,7 @@ sub athena_proc
     # CONTRIB   <user> all system:anyuser rl
     # COURSE    <user> all <group> all system:facdev all system:authuser rl
     # HOMEDIR   <user> all
+    # LEASE    <user> all
     # PROJECT   <user> all <group> all
     # REF       <user> all system:anyuser rl
     # SW        <user> all system:swmaint all system:authuser rl
@@ -120,7 +113,7 @@ sub athena_proc
     push(@acl,"system:swmaint all") if ($type =~ /^(SW)/);
     push(@acl,"system:administrators all") if ($type =~ /^(SYSTEM)/);
     push(@acl,"$user all")
-       if ($uid != 0 && $type =~ /^(ACTIVITY|APROJ|AREF|CONTRIB|COURSE|HOMEDIR|PROJECT|REF|SW|UROP)/);
+       if ($uid != 0 && $type =~ /^(ACTIVITY|APROJ|AREF|CONTRIB|COURSE|HOMEDIR|LEASE|PROJECT|REF|SW|UROP)/);
     push(@acl,"system:$group all")
        if ($gid != 0 && $type =~ /^(ACTIVITY|APROJ|COURSE|PROJECT|UROP)/);
     push(@acl,"system:$group rl") if ($gid != 0 && $type =~ /^(AREF)/);
This page took 0.041254 seconds and 4 git commands to generate.