|
From: Chris W. <la...@us...> - 2001-11-28 06:00:24
|
Update of /cvsroot/openinteract/OpenInteract/script
In directory usw-pr-cvs1:/tmp/cvs-serv1368/script
Modified Files:
oi_manage
Log Message:
cosmetic (mostly)
Index: oi_manage
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/script/oi_manage,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** oi_manage 2001/11/14 12:56:50 1.53
--- oi_manage 2001/11/28 06:00:20 1.54
***************
*** 10,14 ****
use File::Path;
use Getopt::Long qw( GetOptions );
! use OpenInteract::Package;
use OpenInteract::PackageRepository;
use OpenInteract::Startup;
--- 10,14 ----
use File::Path;
use Getopt::Long qw( GetOptions );
! use OpenInteract::Package qw( READONLY_FILE );
use OpenInteract::PackageRepository;
use OpenInteract::Startup;
***************
*** 23,27 ****
use constant DEBUG => 0;
- use constant WIDGET_OVERWRITE_FILE => '.no_overwrite';
# Legitimate commands; anything not listed here will be kicked out and
--- 23,26 ----
***************
*** 1137,1155 ****
sub refresh_widget {
my ( $p ) = @_;
! my $bc = eval { OpenInteract::Startup->read_base_config({ dir => $p->{website_dir} }) };
! if ( $@ ) { base_config_file_error({ website_dir => $p->{website_dir},
! error => $@, sub => 'refresh_widget' }) }
! my $base_widget = "$bc->{base_dir}/template";
! my $site_widget = "$p->{website_dir}/template";
! File::Path::mkpath( $site_widget, 0775, undef ) unless ( -d $site_widget );
! opendir( BASE, $base_widget ) || die "Cannot open base widget directory! ($!)";
! opendir( SITE, $site_widget ) || die "Cannot open website widget directory! ($!)";
! my %base_info = map { $_ => (stat( "$base_widget/$_" ))[7] }
! grep { -f "$base_widget/$_" }
grep ! /old$/,
readdir( BASE );
! my %site_info = map { $_ => (stat( "$site_widget/$_" ))[7] }
! grep { -f "$site_widget/$_" }
grep ! /old$/,
readdir( SITE );
--- 1136,1161 ----
sub refresh_widget {
my ( $p ) = @_;
! my $bc = eval { OpenInteract::Startup->read_base_config({
! dir => $p->{website_dir} }) };
! if ( $@ ) {
! base_config_file_error({ website_dir => $p->{website_dir},
! error => $@, sub => 'refresh_widget' });
! }
! my $base_widget_dir = "$bc->{base_dir}/template";
! my $site_widget_dir = "$p->{website_dir}/template";
! unless ( -d $site_widget_dir ) {
! File::Path::mkpath( $site_widget_dir, 0775, undef );
! }
! opendir( BASE, $base_widget_dir )
! || die "Cannot open base widget directory! ($!)";
! opendir( SITE, $site_widget_dir )
! || die "Cannot open website widget directory! ($!)";
! my %base_info = map { $_ => (stat( "$base_widget_dir/$_" ))[7] }
! grep { -f "$base_widget_dir/$_" }
grep ! /old$/,
readdir( BASE );
! my %site_info = map { $_ => (stat( "$site_widget_dir/$_" ))[7] }
! grep { -f "$site_widget_dir/$_" }
grep ! /old$/,
readdir( SITE );
***************
*** 1157,1173 ****
close( BASE );
! my %no_write = ();
! my $overwrite_check_file = join( '/', $site_widget, WIDGET_OVERWRITE_FILE );
! if ( open( NOWRITE, $overwrite_check_file ) ) {
! while ( <NOWRITE> ) {
! chomp;
! next if ( /^\s*$/ );
! next if ( /^\s*\#/ );
! s/^\s+//;
! s/\s+$//;
! $no_write{ $_ }++;
! }
! close( NOWRITE );
! }
my @status = ();
--- 1163,1167 ----
close( BASE );
! my %no_write = map { $_ => 1 } $PKG_CLASS->read_readonly_file( $site_widget_dir );
my @status = ();
***************
*** 1175,1184 ****
next if ( $no_write{ $base_filename } );
if ( $base_info{ $base_filename } != $site_info{ $base_filename } ) {
! eval { cp( "$base_widget/$base_filename", "$site_widget/$base_filename" ) || die $! };
if ( $@ ) {
! push @status, { filename => $base_filename, ok => 0, error => $@ };
}
else {
! push @status, { filename => $base_filename, ok => 1, copied => 1 };
}
}
--- 1169,1181 ----
next if ( $no_write{ $base_filename } );
if ( $base_info{ $base_filename } != $site_info{ $base_filename } ) {
! eval { cp( "$base_widget_dir/$base_filename",
! "$site_widget_dir/$base_filename" ) || die $! };
if ( $@ ) {
! push @status, { filename => $base_filename,
! ok => 0, error => $@ };
}
else {
! push @status, { filename => $base_filename,
! ok => 1, copied => 1 };
}
}
***************
*** 1197,1201 ****
sub list_actions {
my ( $p ) = @_;
! my $bc = eval { OpenInteract::Startup->read_base_config({ dir => $p->{website_dir} }) };
if ( $@ ) { base_config_file_error({ website_dir => $p->{website_dir},
error => $@,
--- 1194,1199 ----
sub list_actions {
my ( $p ) = @_;
! my $bc = eval { OpenInteract::Startup->read_base_config({
! dir => $p->{website_dir} }) };
if ( $@ ) { base_config_file_error({ website_dir => $p->{website_dir},
error => $@,
***************
*** 1232,1236 ****
sub list_objects {
my ( $p ) = @_;
! my $bc = eval { OpenInteract::Startup->read_base_config({ dir => $p->{website_dir} }) };
if ( $@ ) { base_config_file_error({ website_dir => $p->{website_dir},
error => $@,
--- 1230,1235 ----
sub list_objects {
my ( $p ) = @_;
! my $bc = eval { OpenInteract::Startup->read_base_config({
! dir => $p->{website_dir} }) };
if ( $@ ) { base_config_file_error({ website_dir => $p->{website_dir},
error => $@,
***************
*** 1279,1283 ****
foreach my $sub_dir ( @BASE_SUBDIR ) {
mkdir( "$p->{base_dir}/$sub_dir", 0775 )
! || die "Cannot create subdir ($p->{base_dir}/$sub_dir). Error: $!";
}
--- 1278,1282 ----
foreach my $sub_dir ( @BASE_SUBDIR ) {
mkdir( "$p->{base_dir}/$sub_dir", 0775 )
! || die "Cannot create dir ($p->{base_dir}/$sub_dir). Error: $!";
}
***************
*** 1286,1290 ****
foreach my $file_frag ( @INITIAL_FILES ) {
cp( $file_frag, "$p->{base_dir}/$file_frag" )
! || _w( 0, "Could not copy ($file_frag) to new directory! Error: $!" );
}
--- 1285,1289 ----
foreach my $file_frag ( @INITIAL_FILES ) {
cp( $file_frag, "$p->{base_dir}/$file_frag" )
! || _w( 0, "Could not copy ($file_frag) to new dir! Error: $!" );
}
***************
*** 1296,1303 ****
eval { opendir( CPDIR, $dir_name ) || die $! };
if ( $@ ) {
! _w( 0, "Cannot open dir $dir_name for reading! ($@) Continuing..." );
next COPYDIR;
}
! my @file_list = grep ! /old$/, grep { -f "$dir_name/$_" } readdir( CPDIR );
closedir( CPDIR );
foreach my $file_name ( @file_list ) {
--- 1295,1303 ----
eval { opendir( CPDIR, $dir_name ) || die $! };
if ( $@ ) {
! _w( 0, "Cannot open ($dir_name) for reading! ($@) Continuing..." );
next COPYDIR;
}
! my @file_list = grep ! /old$/,
! grep { -f "$dir_name/$_" } readdir( CPDIR );
closedir( CPDIR );
foreach my $file_name ( @file_list ) {
***************
*** 1401,1408 ****
"$base_dir/$file_frag.old" );
cp( $file_frag, "$base_dir/$file_frag" )
! || _w( 0, "Could not copy ($file_frag) to new directory! Error: $!" );
}
! # Now copy over everything in the 'conf/', 'doc/' and 'template/' directories
COPYDIR:
--- 1401,1409 ----
"$base_dir/$file_frag.old" );
cp( $file_frag, "$base_dir/$file_frag" )
! || _w( 0, "Could not copy ($file_frag) to new dir! Error: $!" );
}
! # Now copy over everything in the 'conf/', 'doc/' and 'template/'
! # directories
COPYDIR:
***************
*** 1410,1414 ****
eval { opendir( CPDIR, $dir_name ) || die $! };
if ( $@ ) {
! _w( 0, "Cannot open dir $dir_name for reading! ($@) Continuing..." );
next COPYDIR;
}
--- 1411,1415 ----
eval { opendir( CPDIR, $dir_name ) || die $! };
if ( $@ ) {
! _w( 0, "Cannot open ($dir_name) for reading! ($@) Continuing..." );
next COPYDIR;
}
***************
*** 1418,1422 ****
next;
}
! my @file_list = grep ! /old$/, grep { -f "$dir_name/$_" } readdir( CPDIR );
closedir( CPDIR );
foreach my $file_name ( @file_list ) {
--- 1419,1424 ----
next;
}
! my @file_list = grep ! /old$/,
! grep { -f "$dir_name/$_" } readdir( CPDIR );
closedir( CPDIR );
foreach my $file_name ( @file_list ) {
***************
*** 1469,1473 ****
my ( $dir ) = @_;
unless ( -d $dir ) {
! die "No valid directory specified to find base packages! (Given: $dir)\n";
}
--- 1471,1475 ----
my ( $dir ) = @_;
unless ( -d $dir ) {
! die "No valid dir specified to find base packages! (Given: $dir)\n";
}
***************
*** 1626,1638 ****
mkdir( $p->{website_dir}, 0775 )
! || die "[oi_manage]: Cannot complete comamnd: cannot create website directory ($p->{website_dir}): $!";
foreach my $sub_dir ( @WEBSITE_SUBDIR, $p->{website_name} ) {
mkdir ( "$p->{website_dir}/$sub_dir", 0775 )
! || die "[oi_manage]: Cannot complete command: failed creating subdir ($p->{website_dir}/$sub_dir): $!";
}
# Do the conf and other files
! cp( "$p->{base_dir}/conf/sample-apache.dat", "$p->{website_dir}/conf/apache.dat" )
|| die "[oi_manage]: Failure! Cannot copy apache module listing: $!";
--- 1628,1643 ----
mkdir( $p->{website_dir}, 0775 )
! || die "[oi_manage]: Cannot complete comamnd: cannot create ",
! "website directory ($p->{website_dir}): $!";
foreach my $sub_dir ( @WEBSITE_SUBDIR, $p->{website_name} ) {
mkdir ( "$p->{website_dir}/$sub_dir", 0775 )
! || die "[oi_manage]: Cannot complete command: failed ",
! "creating subdir ($p->{website_dir}/$sub_dir): $!";
}
# Do the conf and other files
! cp( "$p->{base_dir}/conf/sample-apache.dat",
! "$p->{website_dir}/conf/apache.dat" )
|| die "[oi_manage]: Failure! Cannot copy apache module listing: $!";
***************
*** 1644,1648 ****
eval { mkdir( $html_doc_root, 0775 ) || die $! };
if ( $@ ) {
! _w( 0, "Cannot create directory 'html/oi_docs' in website directory, \n",
"so I cannot copy OpenInteract documentation to viewable ",
"location. Continuing..." );
--- 1649,1653 ----
eval { mkdir( $html_doc_root, 0775 ) || die $! };
if ( $@ ) {
! _w( 0, "Cannot create dir 'html/oi_docs' in website directory, \n",
"so I cannot copy OpenInteract documentation to viewable ",
"location. Continuing..." );
***************
*** 1652,1664 ****
eval { opendir( DOC, $oi_doc_root ) || die $! };
if ( $@ ) {
! _w( 0, "Cannot read system documentation from ($oi_doc_root). Please ask\n",
"your system administrator to install it there..\n",
"Continuing without system documentation available." );
}
else {
! my @file_list = grep ! /old$/, grep { -f "$oi_doc_root/$_" } readdir( DOC );
foreach my $file_name ( @file_list ) {
cp( "$oi_doc_root/$file_name", "$html_doc_root/$file_name" )
! || _w( 0, "Could not copy ($file_name) from system documentation directory ($!)." );
}
}
--- 1657,1672 ----
eval { opendir( DOC, $oi_doc_root ) || die $! };
if ( $@ ) {
! _w( 0, "Cannot read system docs from ($oi_doc_root). Please ask\n",
"your system administrator to install it there..\n",
"Continuing without system documentation available." );
}
else {
! my @file_list = grep ! /old$/,
! grep { -f "$oi_doc_root/$_" }
! readdir( DOC );
foreach my $file_name ( @file_list ) {
cp( "$oi_doc_root/$file_name", "$html_doc_root/$file_name" )
! || _w( 0, "Could not copy ($file_name) from system ",
! "documentation directory ($!)." );
}
}
***************
*** 1673,1694 ****
eval { opendir( DOC, $base_template_root ) || die $! };
if ( $@ ) {
! _w( 0, "Cannot read template widgets from ($base_template_root). Please ask\n",
! "your system administrator to install it there..\n",
"Continuing without template widgets available." );
}
else {
! my @file_list = grep ! /old$/, grep { -f "$base_template_root/$_" } readdir( DOC );
foreach my $file_name ( @file_list ) {
cp( "$base_template_root/$file_name", "$site_template_root/$file_name" )
|| _w( 0, "Could not copy ($file_name) from base template widget ($!)." );
}
! my $no_overwrite_file = join( '/', $site_template_root, WIDGET_OVERWRITE_FILE );
! open( NOWRITE, "> $no_overwrite_file" )
! || _w( 0, "Could not create ($no_overwrite_file): $!" );
! print NOWRITE qq(\# These are templates that will not be overwritten when you\n),
! qq(\# run 'oi_manage refresh_widget' (one per line)\n\n),
! qq(base_main\n),
! qq(base_simple\n);
! close( NOWRITE );
}
--- 1681,1705 ----
eval { opendir( DOC, $base_template_root ) || die $! };
if ( $@ ) {
! _w( 0, "Cannot read template widgets from ($base_template_root).",
! "Please ask your administrator to install it there.\n",
"Continuing without template widgets available." );
}
else {
! my @file_list = grep ! /old$/,
! grep { -f "$base_template_root/$_" }
! readdir( DOC );
foreach my $file_name ( @file_list ) {
cp( "$base_template_root/$file_name", "$site_template_root/$file_name" )
|| _w( 0, "Could not copy ($file_name) from base template widget ($!)." );
}
! my $template_msg = <<TMPLMSG;
! # These are templates that will not be overwritten
! # when you run 'oi_manage refresh_widget' (one
! # template filename per line)
!
! base_main
! base_simple
! TMPLMSG
! create_readonly_file( $site_template_root, $template_msg );
}
***************
*** 1698,1710 ****
my %file_match = (
! "conf/sample-Stash.pm" => "$p->{website_name}/Stash.pm",
! "conf/sample-httpd_modperl.conf" => "conf/httpd_modperl.conf",
! "conf/sample-httpd_modperl_solo.conf" => "conf/httpd_modperl_solo.conf",
! "conf/sample-httpd_static.conf" => "conf/httpd_static.conf",
! "conf/sample-base.conf" => "conf/base.conf",
! "conf/sample-server.perl" => "conf/server.perl",
! "conf/sample-server.ini" => "conf/server.ini",
! "conf/sample-startup.pl" => "conf/startup.pl",
! "INSTALL.website" => "INSTALL.website"
);
my $replace_keys = [ '%%INTERACT_DIR%%', '%%WEBSITE_DIR%%',
--- 1709,1721 ----
my %file_match = (
! "conf/sample-Stash.pm" => "$p->{website_name}/Stash.pm",
! "conf/sample-httpd_modperl.conf" => "conf/httpd_modperl.conf",
! "conf/sample-httpd_modperl_solo.conf" => "conf/httpd_modperl_solo.conf",
! "conf/sample-httpd_static.conf" => "conf/httpd_static.conf",
! "conf/sample-base.conf" => "conf/base.conf",
! "conf/sample-server.perl" => "conf/server.perl",
! "conf/sample-server.ini" => "conf/server.ini",
! "conf/sample-startup.pl" => "conf/startup.pl",
! "INSTALL.website" => "INSTALL.website"
);
my $replace_keys = [ '%%INTERACT_DIR%%', '%%WEBSITE_DIR%%',
***************
*** 1723,1730 ****
}
! return apply_package({ package => \@WEBSITE_BASE_PKG,
! base_dir => $p->{base_dir},
! website_name => $p->{website_name},
! website_dir => $p->{website_dir} });
}
--- 1734,1754 ----
}
! # First apply all the packages...
!
! my $status_list = apply_package({ package => \@WEBSITE_BASE_PKG,
! base_dir => $p->{base_dir},
! website_name => $p->{website_name},
! website_dir => $p->{website_dir} });
!
! # Then create a nowrite flag for the index.html page
!
! my $html_msg = <<HTMLMSG;
! # If a file is listed here it will not be updated when
! # the package to which it belongs is updated.
!
! index.html
! HTMLMSG
! create_readonly_file( "$p->{website_dir}/html", $html_msg );
! return $status_list;
}
***************
*** 2673,2676 ****
--- 2697,2714 ----
$status->{msg} = join "\n", @msg;
return $status;
+ }
+
+
+ #
+ # create_readonly_file
+ #
+
+ sub create_readonly_file {
+ my ( $dir, $msg ) = @_;
+ my $no_overwrite_file = join( '/', $dir, READONLY_FILE );
+ open( NOWRITE, "> $no_overwrite_file" )
+ || _w( 0, "Could not create ($no_overwrite_file): $!" );
+ print NOWRITE $msg;
+ close( NOWRITE );
}
|