Annotation of loncom/build/loncaparestoreconfigurations, revision 1.5

1.1       harris41    1: #!/usr/bin/perl
                      2: 
                      3: # loncaparestoreconfigurations
                      4: 
                      5: # This tool helps in updating a system.  It takes a list of
                      6: # .rpmsave files and restores them.
                      7: 
                      8: # Scott Harrison, 10/25/2000
                      9: 
                     10: use strict;
                     11: 
                     12: my @special_conf_files=(
1.5     ! harris41   13: 			"/etc/httpd/conf/access.conf",
        !            14: 			"/etc/smb.conf"
1.1       harris41   15: 			);
                     16: 
                     17: my @generic_conf_files=(
                     18: 			"/home/httpd/lonTabs/hosts.tab",
                     19: 			"/home/httpd/lonTabs/spare.tab",
                     20: 			"/etc/krb.conf",
1.4       harris41   21: 			"/etc/ntp.conf",
1.1       harris41   22: 			);
                     23: 
1.5     ! harris41   24: my @perlsetvars=("lonHostID","lonRole","lonAdmEMail","lonDefDomain","lonLoadLim","lonExpire");
1.1       harris41   25: foreach (@special_conf_files) {
1.3       harris41   26:     if (/^\/etc\/httpd\/conf\/access.conf$/) {
1.2       harris41   27: 	my $template=`/bin/cat /etc/httpd/conf/access.conf`;
                     28: 	my $rpmsave=`/bin/cat /etc/httpd/conf/access.conf.rpmsave`;
                     29: 	`/bin/mv /etc/httpd/conf/access.conf /etc/httpd/conf/access.conf.template`;
                     30: 	foreach my $psv (@perlsetvars) {
                     31: 	    $rpmsave=~/\nPerlSetVar\s+$psv\s+(\S+)/;
                     32: 	    my $pval=$1;
                     33: 	    $template=~s/(\nPerlSetVar\s+$psv\s+)\S+/$1$pval/;
1.5     ! harris41   34: 	    $pvar{$psv}=$pval;
1.2       harris41   35: 	}
                     36: 	open OUT,">/etc/httpd/conf/access.conf";
1.5     ! harris41   37: 	print OUT $template;
        !            38: 	close OUT;
        !            39:     }
        !            40:     if (/^\/etc\/smb.conf$/) {
        !            41: 	my $template=`/bin/cat /etc/httpd/conf/access.conf`;
        !            42: 	foreach my $psv (@perlsetvars) {
        !            43: 	    $template=~s/\{\{\{\{\[(.*?)\]\}\}\}\}/$pvar{$1}/ge;
        !            44: 	}
        !            45: 	open OUT,">/etc/smb.conf";
1.2       harris41   46: 	print OUT $template;
                     47: 	close OUT;
1.1       harris41   48:     }
                     49: }
                     50: 
                     51: foreach (@generic_conf_files) {
1.3       harris41   52:     if (-e "$_.rpmsave") {
                     53: 	`/bin/mv $_ $_.template`;
                     54: 	`/bin/mv $_.rpmsave $_`;
                     55:     }
1.1       harris41   56: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>