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=(
13: "/etc/httpd/conf/access.conf",
14: "/etc/smb.conf"
15: );
16:
17: my @generic_conf_files=(
18: "/home/httpd/lonTabs/hosts.tab",
19: "/home/httpd/lonTabs/spare.tab",
20: "/etc/krb.conf",
21: "/etc/ntp.conf",
22: );
23:
24: my @perlsetvars=("lonHostID","lonRole","lonAdmEMail","lonDefDomain","lonLoadLim","lonExpire");
25: foreach (@special_conf_files) {
26: if (/^\/etc\/httpd\/conf\/access.conf$/) {
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/;
34: $pvar{$psv}=$pval;
35: }
36: open OUT,">/etc/httpd/conf/access.conf";
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";
46: print OUT $template;
47: close OUT;
48: }
49: }
50:
51: foreach (@generic_conf_files) {
52: if (-e "$_.rpmsave") {
53: `/bin/mv $_ $_.template`;
54: `/bin/mv $_.rpmsave $_`;
55: }
56: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>