File:  [LON-CAPA] / loncom / build / loncaparestoreconfigurations
Revision 1.5: download - view: text, annotated - select for diffs
Thu Nov 2 17:26:21 2000 UTC (23 years, 6 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
fixing smb.conf so that it is configured off of access.conf

#!/usr/bin/perl

# loncaparestoreconfigurations

# This tool helps in updating a system.  It takes a list of
# .rpmsave files and restores them.

# Scott Harrison, 10/25/2000

use strict;

my @special_conf_files=(
			"/etc/httpd/conf/access.conf",
			"/etc/smb.conf"
			);

my @generic_conf_files=(
			"/home/httpd/lonTabs/hosts.tab",
			"/home/httpd/lonTabs/spare.tab",
			"/etc/krb.conf",
			"/etc/ntp.conf",
			);

my @perlsetvars=("lonHostID","lonRole","lonAdmEMail","lonDefDomain","lonLoadLim","lonExpire");
foreach (@special_conf_files) {
    if (/^\/etc\/httpd\/conf\/access.conf$/) {
	my $template=`/bin/cat /etc/httpd/conf/access.conf`;
	my $rpmsave=`/bin/cat /etc/httpd/conf/access.conf.rpmsave`;
	`/bin/mv /etc/httpd/conf/access.conf /etc/httpd/conf/access.conf.template`;
	foreach my $psv (@perlsetvars) {
	    $rpmsave=~/\nPerlSetVar\s+$psv\s+(\S+)/;
	    my $pval=$1;
	    $template=~s/(\nPerlSetVar\s+$psv\s+)\S+/$1$pval/;
	    $pvar{$psv}=$pval;
	}
	open OUT,">/etc/httpd/conf/access.conf";
	print OUT $template;
	close OUT;
    }
    if (/^\/etc\/smb.conf$/) {
	my $template=`/bin/cat /etc/httpd/conf/access.conf`;
	foreach my $psv (@perlsetvars) {
	    $template=~s/\{\{\{\{\[(.*?)\]\}\}\}\}/$pvar{$1}/ge;
	}
	open OUT,">/etc/smb.conf";
	print OUT $template;
	close OUT;
    }
}

foreach (@generic_conf_files) {
    if (-e "$_.rpmsave") {
	`/bin/mv $_ $_.template`;
	`/bin/mv $_.rpmsave $_`;
    }
}

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