version 1.6, 2000/11/02 17:30:45
|
version 1.8, 2000/12/14 17:38:38
|
Line 2
|
Line 2
|
|
|
# loncaparestoreconfigurations |
# loncaparestoreconfigurations |
|
|
# This tool helps in updating a system. It takes a list of |
|
# .rpmsave files and restores them. |
|
|
|
# Scott Harrison, 10/25/2000 |
# Scott Harrison, 10/25/2000 |
|
# Scott Harrison, 12/14/2000 |
|
|
|
# This tool helps in updating a system. It restores backed-up |
|
# configuration files (.rpmsave or other backup notations). |
|
|
|
# By default, the .rpmsave suffix is used. |
|
# Alternatively, there can be two other invocations |
|
# Invocation #1: |
|
# ARGV[0]=suffix |
|
# ARGV[1]=.bak |
|
# Invocation #2: |
|
# ARGV[0]=lasttimestamp |
|
|
|
# The criteria for the lasttimestamp is that the |
|
# file suffix is a '.' followed by a 14-digit |
|
# time-stamp (YYYYMMDDhhmmss). |
|
# The time-stamp with the greatest value is |
|
# taken as the backup file. |
|
|
|
my $suffix=".rpmsave"; |
|
my $suffixpragma=""; |
|
if ($ARGV[0] eq 'suffix') { |
|
$suffix=$ARGV[1] if $suffix=~/^[\.\w]+$/; |
|
} |
|
elsif ($ARGV[0] eq 'lasttimestamp') { |
|
$suffixpragma="lasttimestamp"; |
|
} |
|
|
|
|
use strict; |
use strict; |
|
|
Line 25 my @perlsetvars=("lonHostID","lonRole","
|
Line 50 my @perlsetvars=("lonHostID","lonRole","
|
my %pvar; |
my %pvar; |
foreach (@special_conf_files) { |
foreach (@special_conf_files) { |
if (/^\/etc\/httpd\/conf\/access.conf$/) { |
if (/^\/etc\/httpd\/conf\/access.conf$/) { |
|
if ($suffixpragma eq 'lasttimestamp') { |
|
$suffix=getsuffix('/etc/httpd/conf/access.conf'); |
|
} |
my $template=`/bin/cat /etc/httpd/conf/access.conf`; |
my $template=`/bin/cat /etc/httpd/conf/access.conf`; |
my $rpmsave=`/bin/cat /etc/httpd/conf/access.conf.rpmsave`; |
my $rpmsave=`/bin/cat /etc/httpd/conf/access.conf$suffix`; |
`/bin/mv /etc/httpd/conf/access.conf /etc/httpd/conf/access.conf.template`; |
`/bin/mv /etc/httpd/conf/access.conf /etc/httpd/conf/access.conf.template`; |
foreach my $psv (@perlsetvars) { |
foreach my $psv (@perlsetvars) { |
$rpmsave=~/\nPerlSetVar\s+$psv\s+(\S+)/; |
$rpmsave=~/\nPerlSetVar\s+$psv\s+(\S+)/; |
Line 39 foreach (@special_conf_files) {
|
Line 67 foreach (@special_conf_files) {
|
close OUT; |
close OUT; |
} |
} |
if (/^\/etc\/smb.conf$/) { |
if (/^\/etc\/smb.conf$/) { |
my $template=`/bin/cat /etc/httpd/conf/access.conf`; |
if ($suffixpragma eq 'lasttimestamp') { |
|
$suffix=getsuffix('/etc/smb.conf'); |
|
} |
|
my $template=`/bin/cat /etc/smb.conf`; |
foreach my $psv (@perlsetvars) { |
foreach my $psv (@perlsetvars) { |
$template=~s/\{\{\{\{\[(.*?)\]\}\}\}\}/$pvar{$1}/ge; |
$template=~s/\{\{\{\{\[(.*?)\]\}\}\}\}/$pvar{$1}/ge; |
} |
} |
Line 50 foreach (@special_conf_files) {
|
Line 81 foreach (@special_conf_files) {
|
} |
} |
|
|
foreach (@generic_conf_files) { |
foreach (@generic_conf_files) { |
if (-e "$_.rpmsave") { |
my $file=$_; |
`/bin/mv $_ $_.template`; |
if ($suffixpragma eq 'lasttimestamp') { |
`/bin/mv $_.rpmsave $_`; |
$suffix=getsuffix($file); |
} |
} |
|
if (-e "$file$suffix") { |
|
`/bin/mv $file $_.template`; |
|
`/bin/cp $file$suffix $file`; |
|
} |
|
} |
|
|
|
sub getsuffix { |
|
my ($file)=@_; |
|
print "$file\n"; |
|
my $dir=$file; $dir=~s/([^\/]+)$//; |
|
my $filename=$1; |
|
opendir(DIR,$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]; |
|
return $suffix; |
} |
} |