[LON-CAPA-cvs] cvs: loncom /build loncaparestoreconfigurations

harris41 lon-capa-cvs@mail.lon-capa.org
Wed, 22 Jan 2003 02:00:01 -0000


This is a MIME encoded message

--harris411043200801
Content-Type: text/plain

harris41		Tue Jan 21 21:00:01 2003 EDT

  Modified files:              
    /loncom/build	loncaparestoreconfigurations 
  Log:
  removing deprecated sections; updating documentation; beautification fixes
  (BUG 1185 PARTIAL FIX)
  
  
--harris411043200801
Content-Type: text/plain
Content-Disposition: attachment; filename="harris41-20030121210001.txt"

Index: loncom/build/loncaparestoreconfigurations
diff -u loncom/build/loncaparestoreconfigurations:1.14 loncom/build/loncaparestoreconfigurations:1.15
--- loncom/build/loncaparestoreconfigurations:1.14	Sat Jul 27 18:39:56 2002
+++ loncom/build/loncaparestoreconfigurations	Tue Jan 21 21:00:01 2003
@@ -2,17 +2,21 @@
 
 # loncaparestoreconfigurations - restore data to new LON-CAPA conf files
 #
-# $Id: loncaparestoreconfigurations,v 1.14 2002/07/27 22:39:56 harris41 Exp $
+# $Id: loncaparestoreconfigurations,v 1.15 2003/01/22 02:00:01 harris41 Exp $
 #
 # YEAR=2000
-# 10/25, 12/14 Scott Harrison
+# Scott Harrison 10/25, 11/02, 12/14
+# YEAR=2001
+# Scott Harrison 05/09, 06/01, 11/27
 # YEAR=2002
-# Scott Harrison, 05/15
+# Scott Harrison 03/03, 05/15, 7/27
+# YEAR=2003
+# Scott Harrison 01/21
 #
 ###
 
 # This tool helps in updating a system.  It restores information for
-# configuration files (.lpmlsave or other backup notations).
+# configuration files (.lpmlnew or other backup notations).
 
 # By default, the .lpmlsave suffix is used.
 # Alternatively, there can be two other invocations
@@ -29,7 +33,7 @@
 # taken as the backup file.
 
 # --------------------------------------------- Define program version variable
-$VERSION = sprintf("%d.%02d", q$Revision: 1.14 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 1.15 $ =~ /(\d+)\.(\d+)/);
 
 # ---------------------------------------------- Process command-line arguments
 my $suffix='.lpmlsave';
@@ -46,7 +50,6 @@
 # ------------------------------------ Configuration files to be concerned with
 my @special_conf_files=(
 			'/etc/httpd/conf/loncapa.conf',
-			'/etc/httpd/conf/access.conf',
 			);
 
 my %pvar; # store the PerlSetVar variable key/value combinations
@@ -63,142 +66,131 @@
 
     my $lpmlnew_file; # file location of information that needs to be modified
 
-# ------------------------------------------- access.conf (becoming deprecated)
-    if (/^\/etc\/httpd\/conf\/access.conf$/ and
-	-e '/etc/httpd/conf/access.conf') {
-	if ($suffixpragma eq 'lasttimestamp' and
-	    -e '/etc/httpd/conf/access.conf'.$suffix) {
-	    $suffix=&getsuffix('/etc/httpd/conf/access.conf');
-	    unless (-e '/etc/httpd/conf/access.conf'.$suffix) {
-		next CONFLOOP;
-	    }
-	    $lpmlold="\n".&readfile('/etc/httpd/conf/access.conf'.$suffix);
-	    $lpmlnew_file='/etc/httpd/conf/access.conf';
-	    $lpmlnew=&readfile($lpmlnew_file);
-	}
-	else {
-	    $lpmlold="\n".&readfile('/etc/httpd/conf/access.conf');
-	    $lpmlnew_file='/etc/httpd/conf/access.conf'.$suffix;
-	    unless (-e $lpmlnew_file) {
-		next CONFLOOP;
-	    }
-	    $lpmlnew=&readfile($lpmlnew_file);
-	}
-	while($lpmlold=~/\n\s*PerlSetVar\s+(\S+)\s+(\S+)/mcg) {
-	    my $pkey=$1; my $pval=$2;
-	    $lpmlnew=~s/(\n\s*PerlSetVar\s+$pkey\s+)\S+/$1$pval/;
-	    $pvar{$pkey}=$pval;
-	}
-    }
-
 # ---------------------------------------------------------------- loncapa.conf
-    elsif (/^\/etc\/httpd\/conf\/loncapa.conf$/ and
-	-e '/etc/httpd/conf/loncapa.conf') {
+    if (/^\/etc\/httpd\/conf\/loncapa.conf$/ and
+	-e '/etc/httpd/conf/loncapa.conf')
+      {
 	if ($suffixpragma eq 'lasttimestamp' and
-	    -e '/etc/httpd/conf/loncapa.conf') {
+	    -e '/etc/httpd/conf/loncapa.conf')
+	  {
 	    $suffix=&getsuffix('/etc/httpd/conf/loncapa.conf');
-	    unless (-e '/etc/httpd/conf/loncapa.conf'.$suffix) {
+	    unless (-e '/etc/httpd/conf/loncapa.conf'.$suffix)
+	      {
 		next CONFLOOP;
-	    }
+	      }
 	    $lpmlold="\n".&readfile('/etc/httpd/conf/loncapa.conf'.$suffix);
 	    $lpmlnew_file='/etc/httpd/conf/loncapa.conf';
 	    $lpmlnew=&readfile($lpmlnew_file);
-	}
-	else {
+	  }
+	else
+	  {
 	    $lpmlold="\n".&readfile('/etc/httpd/conf/loncapa.conf');
 	    $lpmlnew_file='/etc/httpd/conf/loncapa.conf'.$suffix;
-	    unless (-e $lpmlnew_file) {
+	    unless (-e $lpmlnew_file)
+	      {
 		next CONFLOOP;
-	    }
+	      }
 	    $lpmlnew=&readfile($lpmlnew_file);
-	}
-	while($lpmlold=~/\n\s*PerlSetVar\s+(\S+)\s+(\S+)/mcg) {
+	  }
+	while($lpmlold=~/\n\s*PerlSetVar\s+(\S+)\s+(\S+)/mcg)
+	  {
 	    my $pkey=$1; my $pval=$2;
 	    $pvar{$pkey}=$pval;
-	}
-	foreach my $pkey (keys %pvar) {
+	  }
+	foreach my $pkey (keys %pvar)
+	  {
 	    my $pval=$pvar{$pkey};
 	    $lpmlnew=~s/(\n\s*PerlSetVar\s+$pkey\s+)\S+/$1$pval/;
-	}
+	  }
 	open(OUT,'>'.$lpmlnew_file) or
 	    die('Cannot open '.$lpmlnew_file.' for output'."\n");
 	print(OUT $lpmlnew);
 	close(OUT);
-    }
+      }
 
-# -------------------------------------------------------------------- smb.conf
-    elsif (/^\/etc\/smb.conf$/ and -e "/etc/smb.conf$suffix") {
-	if ($suffixpragma eq 'lasttimestamp') {
+# ---------------------- smb.conf (probably will be deprecated in 2004 or 2005)
+    elsif (/^\/etc\/smb.conf$/ and -e "/etc/smb.conf$suffix")
+      {
+	if ($suffixpragma eq 'lasttimestamp')
+	  {
 	    $suffix=&getsuffix('/etc/smb.conf');
-	    unless (-e '/etc/httpd/conf/loncapa.conf'.$suffix) {
+	    unless (-e '/etc/httpd/conf/loncapa.conf'.$suffix)
+	      {
 		next CONFLOOP;
-	    }
-	    $lpmlnew=&readfile('/etc/smb.conf');
-	    $lpmlnew_file='/etc/smb.conf';
-	}
-	else {
-	    $lpmlnew=&readfile('/etc/smb.conf'.$suffix);
-	    $lpmlnew_file='/etc/smb.conf'.$suffix;
-	}
-	$lpmlnew=~s/\{\{\{\{\[(.*?)\]\}\}\}\}/$pvar{$1}/ge;
+	      }
+	    $lpmlnew = &readfile('/etc/smb.conf');
+	    $lpmlnew_file = '/etc/smb.conf';
+	  }
+	else
+	  {
+	    $lpmlnew = &readfile('/etc/smb.conf'.$suffix);
+	    $lpmlnew_file = '/etc/smb.conf'.$suffix;
+	  }
+	$lpmlnew =~ s/\{\{\{\{\[(.*?)\]\}\}\}\}/$pvar{$1}/ge;
 	open(OUT,'>'.$lpmlnew_file) or
 	    die('Cannot open '.$lpmlnew_file.' for output'."\n");
 	print(OUT $lpmlnew);
 	close(OUT);
-    }
-    elsif (/^\/etc\/samba\/smb.conf$/ and -e "/etc/samba/smb.conf$suffix") {
-	if ($suffixpragma eq 'lasttimestamp') {
-	    $suffix=&getsuffix('/etc/samba/smb.conf');
-	    unless (-e '/etc/samba/smb.conf'.$suffix) {
+      }
+    elsif (/^\/etc\/samba\/smb.conf$/ and -e "/etc/samba/smb.conf$suffix")
+      {
+	if ($suffixpragma eq 'lasttimestamp')
+	  {
+	    $suffix = &getsuffix('/etc/samba/smb.conf');
+	    unless (-e '/etc/samba/smb.conf'.$suffix)
+	      {
 		next CONFLOOP;
-	    }
-	    $lpmlnew=&readfile('/etc/samba/smb.conf');
-	    $lpmlnew_file='/etc/samba/smb.conf';
-	}
-	else {
-	    $lpmlnew=&readfile('/etc/samba/smb.conf'.$suffix);
-	    $lpmlnew_file='/etc/samba/smb.conf'.$suffix;
-	}
-	$lpmlnew=~s/\{\{\{\{\[(.*?)\]\}\}\}\}/$pvar{$1}/ge;
+	      }
+	    $lpmlnew = &readfile('/etc/samba/smb.conf');
+	    $lpmlnew_file = '/etc/samba/smb.conf';
+	  }
+	else
+	  {
+	    $lpmlnew = &readfile('/etc/samba/smb.conf'.$suffix);
+	    $lpmlnew_file = '/etc/samba/smb.conf'.$suffix;
+	  }
+	$lpmlnew =~ s/\{\{\{\{\[(.*?)\]\}\}\}\}/$pvar{$1}/ge;
 	open(OUT,'>'.$lpmlnew_file) or
 	    die('Cannot open '.$lpmlnew_file.' for output'."\n");
 	print(OUT $lpmlnew);
 	close(OUT);
-    }
-}
+      }
+  }
 
 # --------------------------------- getsuffix: get the latest time stamp suffix
 # === INPUT:  filename without suffix
 # === OUTPUT: the latest time stamp suffix; 14 digits YYYYMMDDhhmmss
 # === ERROR:  cannot read the directory in which the filenames reside
-sub getsuffix {
-    my ($file)=@_;
+sub getsuffix ($)
+  {
+    my ($file) = @_;
     print("$file\n");
-    my $dir=$file; $dir=~s/([^\/]+)$//;
-    my $filename=$1;
+    my $dir = $file; $dir =~ s/([^\/]+)$//;
+    my $filename = $1;
     opendir(DIR,$dir) or
 	die('Cannot open directory '.$dir.' for viewing'."\n");
-    my @a=grep {/$filename\.\d{14}/} readdir(DIR);
+    my @a = grep {/$filename\.\d{14}/} readdir(DIR);
     closedir(DIR);
     map {s/$filename\.//;} @a;
-    my @b=sort {$a<=>$b} @a;
-    my $suffix='.'.$b[$#b];
+    my @b = sort {$a<=>$b} @a;
+    my $suffix = '.'.$b[$#b];
     return($suffix);
-}
+  }
 
 # -------------------------- readfile: get the file contents in a scalar string
 # === INPUT:  filename
 # === OUTPUT: the filename's contents
 # === ERROR:  cannot read the file
 # === NOTE:   big files will hog computer memory
-sub readfile {
-    my ($filename)=@_;
-    my $contents='';
+sub readfile ($)
+  {
+    my ($filename) = @_;
+    my $contents = '';
     open(IN,'<'.$filename) or die ('Cannot read '.$filename."\n");
-    while(<IN>) {$contents.=$_;}
+    while(<IN>) {$contents .= $_;}
     close(IN);
     return($contents);
-}
+  }
 
 =pod
 
@@ -311,7 +303,7 @@
 
 Scott Harrison
 
-This module is free software; you can redistribute it
+This script is free software; you can redistribute it
 and/or modify it under the same terms as LON-CAPA itself.
 
 =cut

--harris411043200801--