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: my %pvar;
26: foreach (@special_conf_files) {
27: if (/^\/etc\/httpd\/conf\/access.conf$/) {
28: my $template=`/bin/cat /etc/httpd/conf/access.conf`;
29: my $rpmsave=`/bin/cat /etc/httpd/conf/access.conf.rpmsave`;
30: `/bin/mv /etc/httpd/conf/access.conf /etc/httpd/conf/access.conf.template`;
31: foreach my $psv (@perlsetvars) {
32: $rpmsave=~/\nPerlSetVar\s+$psv\s+(\S+)/;
33: my $pval=$1;
34: $template=~s/(\nPerlSetVar\s+$psv\s+)\S+/$1$pval/;
35: $pvar{$psv}=$pval;
36: }
37: open OUT,">/etc/httpd/conf/access.conf";
38: print OUT $template;
39: close OUT;
40: }
41: if (/^\/etc\/smb.conf$/) {
42: my $template=`/bin/cat /etc/httpd/conf/access.conf`;
43: foreach my $psv (@perlsetvars) {
44: $template=~s/\{\{\{\{\[(.*?)\]\}\}\}\}/$pvar{$1}/ge;
45: }
46: open OUT,">/etc/smb.conf";
47: print OUT $template;
48: close OUT;
49: }
50: }
51:
52: foreach (@generic_conf_files) {
53: if (-e "$_.rpmsave") {
54: `/bin/mv $_ $_.template`;
55: `/bin/mv $_.rpmsave $_`;
56: }
57: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>