version 1.1, 2013/02/02 00:22:43
|
version 1.7, 2016/02/20 20:58:59
|
Line 34 use strict;
|
Line 34 use strict;
|
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use Apache::lonlocal(); |
use Apache::lonlocal(); |
use Apache::loncommon(); |
use Apache::loncommon(); |
|
use Digest::SHA; |
|
|
sub get_checksums { |
sub get_checksums { |
my ($distro,$londaemons,$lonlib,$lonincludes,$lontabdir) = @_; |
my ($distro,$londaemons,$lonlib,$lonincludes,$lontabdir) = @_; |
Line 62 sub get_checksums {
|
Line 63 sub get_checksums {
|
} |
} |
push(@paths,('/home/httpd/cgi-bin/*.pl','/home/httpd/cgi-bin/*.png')); |
push(@paths,('/home/httpd/cgi-bin/*.pl','/home/httpd/cgi-bin/*.png')); |
my $confdir = '/etc/httpd/conf'; |
my $confdir = '/etc/httpd/conf'; |
my $sha = 'SHA1'; |
|
if ($distro =~ /^(ubuntu|debian)(\d+)$/) { |
if ($distro =~ /^(ubuntu|debian)(\d+)$/) { |
$confdir = '/etc/apache2'; |
$confdir = '/etc/apache2'; |
if (($1 eq 'ubuntu') && ($2 >= 12)) { |
|
$sha = 'SHA'; |
|
} |
|
} elsif ($distro =~ /^sles(\d+)$/) { |
} elsif ($distro =~ /^sles(\d+)$/) { |
if ($1 >= 10) { |
if ($1 >= 10) { |
$confdir = '/etc/apache2'; |
$confdir = '/etc/apache2'; |
Line 78 sub get_checksums {
|
Line 75 sub get_checksums {
|
} |
} |
} |
} |
push(@paths,("$confdir/loncapa_apache.conf","$confdir/startup.pl")); |
push(@paths,("$confdir/loncapa_apache.conf","$confdir/startup.pl")); |
if ($sha eq 'SHA1') { |
|
require Digest::SHA1; |
|
} else { |
|
require Digest::SHA; |
|
} |
|
if (@paths) { |
if (@paths) { |
my $pathstr = join (' ',@paths); |
my $pathstr = join (' ',@paths); |
if (open($dirh,"grep '$revtag' $pathstr |")) { |
if (open($dirh,"grep '$revtag' $pathstr 2>&1 |")) { |
while (my $line=<$dirh>) { |
while (my $line=<$dirh>) { |
if ($line =~ m{^([^#]+):#\s\\s[\w.]+,v\s([\d.]+)\s}) { |
if ($line =~ m{^([^#]+):#\s\\s[\w.]+,v\s([\d.]+)\s}) { |
$versions{$1} = $2; |
$versions{$1} = $2; |
Line 98 sub get_checksums {
|
Line 90 sub get_checksums {
|
my $sum; |
my $sum; |
if (open(my $fh,"<$key")) { |
if (open(my $fh,"<$key")) { |
binmode $fh; |
binmode $fh; |
my $sha_obj; |
my $sha_obj = Digest::SHA->new(); |
if ($sha eq 'SHA') { |
|
$sha_obj = Digest::SHA->new(); |
|
} else { |
|
$sha_obj = Digest::SHA1->new(); |
|
} |
|
$sha_obj->addfile($fh); |
$sha_obj->addfile($fh); |
$sum = $sha_obj->hexdigest; |
$sum = $sha_obj->hexdigest; |
close($fh); |
close($fh); |
Line 124 sub get_checksums {
|
Line 111 sub get_checksums {
|
|
|
sub compare_checksums { |
sub compare_checksums { |
my ($target,$lonhost,$version,$serversums,$serverversions) = @_; |
my ($target,$lonhost,$version,$serversums,$serverversions) = @_; |
my ($message,$numchg); |
my ($message,$numchg,$linefeed); |
|
if ($target eq 'web') { |
|
$linefeed = '<br />'; |
|
} else { |
|
$linefeed = "\n"; |
|
} |
|
if (!$Apache::lonlocal::lh) { |
|
&Apache::lonlocal::get_language_handle(); |
|
} |
if ((ref($serversums) eq 'HASH') && (keys(%{$serversums}))) { |
if ((ref($serversums) eq 'HASH') && (keys(%{$serversums}))) { |
my $checksums = &Apache::lonnet::fetch_dns_checksums(); |
my $checksums = &Apache::lonnet::fetch_dns_checksums(); |
my (%extra,%missing,%diffs,%stdsums,%stdversions); |
my (%extra,%missing,%diffs,%stdsums,%stdversions); |
Line 143 sub compare_checksums {
|
Line 138 sub compare_checksums {
|
$numchg ++; |
$numchg ++; |
} |
} |
} else { |
} else { |
$missing{$key} = 1; |
unless ((-e $key) && (-B $key)) { |
$numchg ++; |
$missing{$key} = 1; |
|
$numchg ++; |
|
} |
} |
} |
} |
} |
foreach my $key (keys(%{$serversums})) { |
foreach my $key (keys(%{$serversums})) { |
Line 155 sub compare_checksums {
|
Line 152 sub compare_checksums {
|
} |
} |
} |
} |
if ($numchg) { |
if ($numchg) { |
$message = |
$message = |
&Apache::lonlocal::mt('[quant,_1,difference was,differences were] found'. |
&Apache::lonlocal::mt('[quant,_1,difference was,differences were] found'. |
' between LON-CAPA modules installed on your server ([_2])'. |
' between LON-CAPA modules installed on your server [_2]'. |
' and those expected for the LON-CAPA version ([_3])'. |
' and those expected for the LON-CAPA version you are'. |
' which you are running.',$numchg,$lonhost,$version); |
' currently running.',$numchg,"($lonhost)$linefeed"); |
if ($target eq 'web') { |
if ($target eq 'web') { |
$message = '<p>'.$message.'</p>'; |
$message = '<p>'.$message.'</p>'; |
} else { |
} else { |
Line 175 sub compare_checksums {
|
Line 172 sub compare_checksums {
|
} |
} |
} |
} |
if (@diffversion > 0) { |
if (@diffversion > 0) { |
my $text = |
my $text = |
&Apache::lonlocal::mt('The following [quant,_1,local file is a,local files are]'. |
&Apache::lonlocal::mt('The following [quant,_1,file is a,files are]'. |
' different version(s) from that expected for LON-CAPA [_2]:', |
' different version(s) from that expected for LON-CAPA [_2]:', |
scalar(@diffversion),$version); |
scalar(@diffversion),$version); |
if ($target eq 'web') { |
if ($target eq 'web') { |
Line 194 sub compare_checksums {
|
Line 191 sub compare_checksums {
|
my $revnum = $stdversions{$file}; |
my $revnum = $stdversions{$file}; |
if ($target eq 'web') { |
if ($target eq 'web') { |
$message .= &Apache::loncommon::start_data_table_row(). |
$message .= &Apache::loncommon::start_data_table_row(). |
'<td>'.$file.'<td>'."\n". |
'<td>'.$file.'</td>'."\n". |
'<td>'.$serverversions->{$file}.'</td>'."\n". |
'<td>'.$serverversions->{$file}.'</td>'."\n". |
'<td>'.$revnum.'</td>'."\n". |
'<td>'.$revnum.'</td>'."\n". |
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
Line 210 sub compare_checksums {
|
Line 207 sub compare_checksums {
|
$message .= "\n"; |
$message .= "\n"; |
} |
} |
} |
} |
|
if ($target eq 'web') { |
|
$message .= &Apache::loncommon::end_data_table().'<br />'; |
|
} else { |
|
$message .= "\n"; |
|
} |
} |
} |
if (@modified > 0) { |
if (@modified > 0) { |
my $text = |
my $text = |
&Apache::lonlocal::mt('The following [quant,_1,file appears,files appear]'. |
&Apache::lonlocal::mt('The following [quant,_1,file appears,files appear]'. |
' to have been modified locally:',scalar(@modified)); |
' to have been modified locally:',scalar(@modified)); |
if ($target eq 'web') { |
if ($target eq 'web') { |
Line 238 sub compare_checksums {
|
Line 240 sub compare_checksums {
|
"\n"; |
"\n"; |
} |
} |
} |
} |
|
if ($target eq 'web') { |
|
$message .= &Apache::loncommon::end_data_table().'<br />'; |
|
} else { |
|
$message .= "\n"; |
|
} |
} |
} |
} |
} |
if (keys(%missing) > 0) { |
if (keys(%missing) > 0) { |
Line 257 sub compare_checksums {
|
Line 264 sub compare_checksums {
|
foreach my $file (sort(keys(%missing))) { |
foreach my $file (sort(keys(%missing))) { |
my $revnum = $stdversions{$file}; |
my $revnum = $stdversions{$file}; |
if ($target eq 'web') { |
if ($target eq 'web') { |
$message .= '<td>'.$file.'<td>'."\n". |
$message .= &Apache::loncommon::start_data_table_row()."\n". |
|
'<td>'.$file.'</td>'."\n". |
'<td>'.$revnum.'</td>'."\n". |
'<td>'.$revnum.'</td>'."\n". |
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
} else { |
} else { |
Line 270 sub compare_checksums {
|
Line 278 sub compare_checksums {
|
$message .= "\n"; |
$message .= "\n"; |
} |
} |
} |
} |
|
if ($target eq 'web') { |
|
$message .= &Apache::loncommon::end_data_table(); |
|
} else { |
|
$message .= "\n"; |
|
} |
} |
} |
if (keys(%extra) > 0) { |
if (keys(%extra) > 0) { |
my $text = |
my $text = |
Line 288 sub compare_checksums {
|
Line 301 sub compare_checksums {
|
} |
} |
foreach my $file (sort(keys(%extra))) { |
foreach my $file (sort(keys(%extra))) { |
if ($target eq 'web') { |
if ($target eq 'web') { |
$message .= '<td>'.$file.'<td>'."\n". |
$message .= &Apache::loncommon::start_data_table_row()."\n". |
|
'<td>'.$file.'</td>'."\n". |
'<td>'.$serverversions->{$file}.'</td>'."\n". |
'<td>'.$serverversions->{$file}.'</td>'."\n". |
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
} else { |
} else { |
Line 298 sub compare_checksums {
|
Line 312 sub compare_checksums {
|
"\n"; |
"\n"; |
} |
} |
} |
} |
|
if ($target eq 'web') { |
|
$message .= &Apache::loncommon::end_data_table().'<br />'; |
|
} else { |
|
$message .= "\n"; |
|
} |
} |
} |
} else { |
} else { |
$message = &Apache::lonlocal::mt('No differences detected between installed files and files expected for LON-CAPA [_1]',$version); |
$message = &Apache::lonlocal::mt('No differences detected between installed files and files expected for LON-CAPA [_1]',$version); |