[LON-CAPA-cvs] cvs: doc /loncapafiles accesscount_seed.piml clean_file_permissions.piml reseval_fixup.piml update_queue_slots.piml

raeburn raeburn at source.lon-capa.org
Mon Mar 16 01:25:47 EDT 2015


raeburn		Mon Mar 16 05:25:47 2015 EDT

  Modified files:              
    /doc/loncapafiles	accesscount_seed.piml clean_file_permissions.piml 
                     	reseval_fixup.piml update_queue_slots.piml 
  Log:
  - Avoid time-consuming recursion of user directories when running ./UPDATE
    to fix pre LON-CAPA 2.0 (and pre-2.2 in one case), which will have been
    fixed when library servers were updated to versions 2.2 through 2.10.
  - No pre-2.2 instances currently in the production cluster.  
  
  
-------------- next part --------------
Index: doc/loncapafiles/accesscount_seed.piml
diff -u doc/loncapafiles/accesscount_seed.piml:1.7 doc/loncapafiles/accesscount_seed.piml:1.8
--- doc/loncapafiles/accesscount_seed.piml:1.7	Tue Jan 31 10:33:51 2006
+++ doc/loncapafiles/accesscount_seed.piml	Mon Mar 16 05:25:47 2015
@@ -3,7 +3,7 @@
 <!-- accesscount_seed.piml -->
 <!-- Matthew Hall -->
 
-<!-- $Id: accesscount_seed.piml,v 1.7 2006/01/31 10:33:51 albertel Exp $ -->
+<!-- $Id: accesscount_seed.piml,v 1.8 2015/03/16 05:25:47 raeburn Exp $ -->
 
 <!--
 
@@ -36,35 +36,57 @@
 <target dist="default">/home/httpd/lonUsers</target>
 <perlscript mode="fg">
 
-print "\nUpdating access count storage.  This can take quite a while.\n";
+my $dotransfer;
+if (-e '/etc/loncapa-release') {
+    if (open(PIPE,"cat /etc/loncapa-release.prev |grep '^LON-CAPA release' |")) {
+        if (<PIPE> =~ /^\QLON-CAPA release \E(CVS_HEAD|\d+\.\d+\.\d+\.?\w*)\-\d+$/) {
+            my $previous = $1;
+            unless ($previous eq 'CVS_HEAD') {
+                my ($major,$minor) = ($previous =~ /^(\d+)\.(\d+)\./);
+                if (($major ne '') && ($minor ne '')) {
+                    if ((($major == 2) && ($minor < 10)) | ($major < 2)) {
+                        $dotransfer = 1;
+                    }
+                }
+            }
+        }
+        close(PIPE);
+    }
+}
+
+if ($dotransfer) {
+    print "\nUpdating access count storage.  This can take quite a while.\n";
 
-my $logfile = '/tmp/accesscount_update_log.txt';
+    my $logfile = '/tmp/accesscount_update_log.txt';
 
-# get a list of all user directories
-print "Getting directory listing.\n";
-my @dirs=`find <TARGET /> -type d `;
-my @userdirs=grep(m|/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*|, @dirs);
-
-my $count = 0;
-my $countby = 100;
-print "Updating ".scalar(@userdirs)." files.\n";
-my $char_count = 0;
-foreach my $udir (@userdirs) {
-    if (++$count % $countby == 0) {
-	print("\b" x $char_count);
-        print($count."/".scalar(@userdirs));
-        $char_count = length($count."/".scalar(@userdirs));
+    # get a list of all user directories
+    print "Getting directory listing.\n";
+    my @dirs=`find <TARGET /> -type d `;
+    my @userdirs=grep(m|/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*|, @dirs);
+
+    my $count = 0;
+    my $countby = 100;
+    print "Updating ".scalar(@userdirs)." files.\n";
+    my $char_count = 0;
+    foreach my $udir (@userdirs) {
+        if (++$count % $countby == 0) {
+	    print("\b" x $char_count);
+            print($count."/".scalar(@userdirs));
+            $char_count = length($count."/".scalar(@userdirs));
+        }
+        chomp($udir);
+        my $file = $udir.'/nohist_resevaldata.db';
+        next if (! -e $file);
+        next if (-e $udir.'/nohist_accesscount.db');
+        system('/home/httpd/perl/seed_accesscount.pl '.$file.
+               ' 2>>'.$logfile);
     }
-    chomp($udir);
-    my $file = $udir.'/nohist_resevaldata.db';
-    next if (! -e $file);
-    next if (-e $udir.'/nohist_accesscount.db');
-    system('/home/httpd/perl/seed_accesscount.pl '.$file.
-                ' 2>>'.$logfile);
+    print("\b" x $char_count);
+    print($count."/".scalar(@userdirs));
+    print "\nCompleted!\n";
+} else {
+    print("No update of nohist_accesscount.db files needed.\n");
 }
-print("\b" x $char_count);
-print($count."/".scalar(@userdirs));
-print "\nCompleted!\n";
 </perlscript>
 </file>
 </files>
Index: doc/loncapafiles/clean_file_permissions.piml
diff -u doc/loncapafiles/clean_file_permissions.piml:1.4 doc/loncapafiles/clean_file_permissions.piml:1.5
--- doc/loncapafiles/clean_file_permissions.piml:1.4	Fri Dec  9 16:26:48 2005
+++ doc/loncapafiles/clean_file_permissions.piml	Mon Mar 16 05:25:47 2015
@@ -3,7 +3,7 @@
 <!-- accesscount_seed.piml -->
 <!-- Matthew Hall -->
 
-<!-- $Id: clean_file_permissions.piml,v 1.4 2005/12/09 16:26:48 albertel Exp $ -->
+<!-- $Id: clean_file_permissions.piml,v 1.5 2015/03/16 05:25:47 raeburn Exp $ -->
 
 <!--
 
@@ -36,34 +36,56 @@
 <target dist="default">/home/httpd/lonUsers</target>
 <perlscript mode="fg">
 
-print "\nCleaning up file_permissions.db\n";
+my $cleanup;
+if (-e '/etc/loncapa-release') {
+    if (open(PIPE,"cat /etc/loncapa-release.prev |grep '^LON-CAPA release' |")) {
+        if (<PIPE> =~ /^\QLON-CAPA release \E(CVS_HEAD|\d+\.\d+\.\d+\.?\w*)\-\d+$/) {
+            my $previous = $1;
+            unless ($previous eq 'CVS_HEAD') {
+                my ($major,$minor) = ($previous =~ /^(\d+)\.(\d+)\./);
+                if (($major ne '') && ($minor ne '')) {
+                    if (($major == 2) && ($minor < 10)) {
+                        $docleanup = 1;
+                    }
+                }
+            }
+        }
+        close(PIPE);
+    }
+}
+
+if ($docleanup) {
+    print "\nCleaning up file_permissions.db\n";
 
-my $logfile = '/tmp/clean_file_permissions_log.txt';
+    my $logfile = '/tmp/clean_file_permissions_log.txt';
 
-# get a list of all user directories
-print "Getting directory listing.\n";
-my @dirs=`find <TARGET /> -type d `;
-my @userdirs=grep(m|/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*|, @dirs);
-
-my $count = 0;
-my $countby = 100;
-print "Updating ".scalar(@userdirs)." files.\n";
-my $char_count=0;
-foreach my $udir (@userdirs) {
-    if (++$count % $countby == 0) {
-        print("\b" x $char_count);
-        print($count."/".scalar(@userdirs));
-        $char_count = length($count."/".scalar(@userdirs));
+    # get a list of all user directories
+    print "Getting directory listing.\n";
+    my @dirs=`find <TARGET /> -type d `;
+    my @userdirs=grep(m|/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*|, @dirs);
+
+    my $count = 0;
+    my $countby = 100;
+    print "Updating ".scalar(@userdirs)." files.\n";
+    my $char_count=0;
+    foreach my $udir (@userdirs) {
+        if (++$count % $countby == 0) {
+            print("\b" x $char_count);
+            print($count."/".scalar(@userdirs));
+            $char_count = length($count."/".scalar(@userdirs));
+        }
+        chomp($udir);
+        my $file = $udir.'/file_permissions.db';
+        next if (! -e $file);
+        system('/home/httpd/perl/debug/clean_db.pl '.$file.
+               ' "error%3a%202%20tie%28GDBM%29%20Failed%20while%20attempting%20dump" 2>>'.$logfile);
     }
-    chomp($udir);
-    my $file = $udir.'/file_permissions.db';
-    next if (! -e $file);
-    system('/home/httpd/perl/debug/clean_db.pl '.$file.
-                ' "error%3a%202%20tie%28GDBM%29%20Failed%20while%20attempting%20dump" 2>>'.$logfile);
+    print("\b" x $char_count);
+    print($count."/".scalar(@userdirs));
+    print "\nCompleted!\n";
+} else {
+    print("Clean up of file_permissions.db files not required.\n");
 }
-print("\b" x $char_count);
-print($count."/".scalar(@userdirs));
-print "\nCompleted!\n";
 </perlscript>
 </file>
 </files>
Index: doc/loncapafiles/reseval_fixup.piml
diff -u doc/loncapafiles/reseval_fixup.piml:1.5 doc/loncapafiles/reseval_fixup.piml:1.6
--- doc/loncapafiles/reseval_fixup.piml:1.5	Tue Feb 10 20:54:14 2004
+++ doc/loncapafiles/reseval_fixup.piml	Mon Mar 16 05:25:47 2015
@@ -3,7 +3,7 @@
 <!-- reseval_fixup.piml -->
 <!-- Guy Albertelli -->
 
-<!-- $Id: reseval_fixup.piml,v 1.5 2004/02/10 20:54:14 www Exp $ -->
+<!-- $Id: reseval_fixup.piml,v 1.6 2015/03/16 05:25:47 raeburn Exp $ -->
 
 <!--
 
@@ -35,19 +35,43 @@
 <file>
 <target dist="default">/home/httpd/lonUsers</target>
 <perlscript mode="fg">
-# get a list of all user directories
-my @dirs=`find <TARGET /> -type d `;
-my @userdirs=grep(m|/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*|, @dirs);
-foreach my $udir (@userdirs) {
-  chomp($udir);
-  unless (-e "$udir/nohist_resevaldata.db") {	
-     if (-e "$udir/resevaldata.db") {
-        `mv $udir/resevaldata.db $udir/nohist_resevaldata.db`;
-     }
-     if (-e "$udir/resevaldata.hist") {
-        unlink("$udir/resevaldata.hist");
-     }
-  }
+
+my $doupdate;
+if (-e '/etc/loncapa-release') {
+    if (open(PIPE,"cat /etc/loncapa-release.prev |grep '^LON-CAPA release' |")) {
+        if (<PIPE> =~ /^\QLON-CAPA release \E(CVS_HEAD|\d+\.\d+\.\d+\.?\w*)\-\d+$/) {
+            my $previous = $1;
+            unless ($previous eq 'CVS_HEAD') {
+                my ($major,$minor) = ($previous =~ /^(\d+)\.(\d+)\./);
+                if (($major ne '') && ($minor ne '')) {
+                    if ((($major == 2) && ($minor < 10)) || ($major < 2)) {
+                        $doupdate = 1;
+                    }
+                }
+            }
+        }
+        close(PIPE);
+    }
+}
+
+if ($doupdate) {
+    print("Searching user directories for resevaldata.db files to update.\n");
+    # get a list of all user directories
+    my @dirs=`find <TARGET /> -type d `;
+    my @userdirs=grep(m|/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*|, @dirs);
+    foreach my $udir (@userdirs) {
+        chomp($udir);
+        unless (-e "$udir/nohist_resevaldata.db") {	
+            if (-e "$udir/resevaldata.db") {
+        `       mv $udir/resevaldata.db $udir/nohist_resevaldata.db`;
+            }
+            if (-e "$udir/resevaldata.hist") {
+                unlink("$udir/resevaldata.hist");
+            }
+        }
+    }
+} else {
+    print("Conversion of resevaldata.db (pre 2.0) to nohist_resevaldata.db (2.0 and later) files not required.\n");
 }
 </perlscript>
 </file>
Index: doc/loncapafiles/update_queue_slots.piml
diff -u doc/loncapafiles/update_queue_slots.piml:1.4 doc/loncapafiles/update_queue_slots.piml:1.5
--- doc/loncapafiles/update_queue_slots.piml:1.4	Wed Jun 28 20:48:04 2006
+++ doc/loncapafiles/update_queue_slots.piml	Mon Mar 16 05:25:47 2015
@@ -3,7 +3,7 @@
 <!-- accesscount_seed.piml -->
 <!-- Matthew Hall -->
 
-<!-- $Id: update_queue_slots.piml,v 1.4 2006/06/28 20:48:04 albertel Exp $ -->
+<!-- $Id: update_queue_slots.piml,v 1.5 2015/03/16 05:25:47 raeburn Exp $ -->
 
 <!--
 
@@ -132,15 +132,37 @@
 
 
 sub main {
-     print("Updating grading queue and slot definitions\n");
-     my $perlvar=LONCAPA::Configuration::read_conf('loncapa.conf');
-     find(
-         {
-	     no_chdir   => 1,
-	     wanted     => \&process_gradingqueue_file,
-	 }, 
-         $perlvar->{'lonUsersDir'});
-     print("\n");
+    my $doupdate;
+    if (-e '/etc/loncapa-release') {
+        if (open(PIPE,"cat /etc/loncapa-release.prev |grep '^LON-CAPA release' |")) {
+            if (<PIPE> =~ /^\QLON-CAPA release \E(CVS_HEAD|\d+\.\d+\.\d+\.?\w*)\-\d+$/) {
+                my $previous = $1;
+                unless ($previous eq 'CVS_HEAD') {
+                    my ($major,$minor) = ($previous =~ /^(\d+)\.(\d+)\./);
+                    if (($major ne '') && ($minor ne '')) {
+                        if (($major == 2) && ($minor < 10)) {
+                            $doupdate = 1;
+                        }
+                    }
+                }
+            }
+            close(PIPE);
+        }
+     }
+
+     if ($doupdate) {
+         print("Updating grading queue and slot definitions\n");
+         my $perlvar=LONCAPA::Configuration::read_conf('loncapa.conf');
+         find(
+             {
+	         no_chdir   => 1,
+	         wanted     => \&process_gradingqueue_file,
+	     },
+             $perlvar->{'lonUsersDir'});
+         print("\n");
+     } else {
+         print("Update of grading queue and slot definitions not required.\n"); 
+     }
 }
 
 &main();


More information about the LON-CAPA-cvs mailing list