[interchange-cvs] interchange - heins modified 8 files
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Thu Apr 10 14:05:01 2003
User: heins
Date: 2003-04-10 18:04:24 GMT
Modified: . MANIFEST
Modified: scripts makecat.PL
Modified: dist/foundation catalog.cfg
Modified: dist/foundation/products variable.txt
Modified: dist/lib/UI ichelp.txt
Modified: dist/lib/UI/pages/include/menus MiscFunction.txt
Added: dist/lib/UI/pages/admin transfer_catalog.html
Added: code/UI_Tag xfer_catalog.coretag
Log:
* Add a relatively complete "transfer catalog" facility. It has help in
ichelp, but basically it does this:
1. Exports all non-MySQL and non-PostGres databases to
text files.
2. Dumps all MySQL/Postgres databases via mysqldump or pg_dump.
3. Builds a tar image, optionally saving sessions and temp
files. includes images but *not* splash page html or anything
else under SAMPLEHTML.
Creates a restore script that attempts to:
1. Create a "site.txt" variable database that contains the new
settings for SERVER_NAME, CGI_URL, DOCROOT, etc.
2. Restore the SQL dump files, optionally creating the
DB.
3. Copy the exported text dbs over the backed-up ones.
4. Create the image directory and copy images to it, and symlink
the target directory to the catalog directory.
5. Compile and copy a link program (optional)
6. Add the "Catalog" line to interchange.cfg (optional)
Accessed via Miscellaneous->Backup Functions link (admin/transfer_catalog).
Revision Changes Path
2.97 +4 -2 interchange/MANIFEST
rev 2.97, prev_rev 2.96
Index: MANIFEST
===================================================================
RCS file: /var/cvs/interchange/MANIFEST,v
retrieving revision 2.96
retrieving revision 2.97
diff -u -r2.96 -r2.97
--- MANIFEST 10 Apr 2003 01:04:24 -0000 2.96
+++ MANIFEST 10 Apr 2003 18:04:23 -0000 2.97
@@ -1,3 +1,4 @@
+:w
LICENSE
MANIFEST This list of files
MANIFEST.SKIP
@@ -176,6 +177,7 @@
code/UI_Tag/widget.coretag
code/UI_Tag/write_relative_file.coretag
code/UI_Tag/write_shipping.coretag
+code/UI_Tag/xfer_catalog.coretag
code/UserTag/bar_button.tag
code/UserTag/button.tag
code/UserTag/component.tag
@@ -255,7 +257,6 @@
dist/catalog_before.cfg
dist/error.log
dist/etc/.empty
-dist/etc/jobs/i18n/update_locales
dist/foundation/backup/.empty
dist/foundation/catalog.cfg
dist/foundation/config/additional_fields
@@ -293,8 +294,8 @@
dist/foundation/dbconf/default_db/variable.dbm
dist/foundation/dbconf/default_db/variants.dbm
dist/foundation/dbconf/locales/de_DE.cfg
-dist/foundation/dbconf/locales/nl_NL.cfg
dist/foundation/dbconf/locales/default.cfg
+dist/foundation/dbconf/locales/nl_NL.cfg
dist/foundation/dbconf/mysql/2ndDayAir.dbm
dist/foundation/dbconf/mysql/Ground.dbm
dist/foundation/dbconf/mysql/NextDayAir.dbm
@@ -1066,6 +1067,7 @@
dist/lib/UI/pages/admin/tax_simple.html
dist/lib/UI/pages/admin/test_code.html
dist/lib/UI/pages/admin/trafficstats.html
+dist/lib/UI/pages/admin/transfer_catalog.html
dist/lib/UI/pages/admin/upload_config.html
dist/lib/UI/pages/admin/upload_file.html
dist/lib/UI/pages/admin/upload_image.html
2.20 +7 -3 interchange/scripts/makecat.PL
rev 2.20, prev_rev 2.19
Index: makecat.PL
===================================================================
RCS file: /var/cvs/interchange/scripts/makecat.PL,v
retrieving revision 2.19
retrieving revision 2.20
diff -u -r2.19 -r2.20
--- makecat.PL 27 Jan 2003 19:03:36 -0000 2.19
+++ makecat.PL 10 Apr 2003 18:04:24 -0000 2.20
@@ -3,7 +3,7 @@
#
# Interchange catalog configurator
#
-# $Id: makecat.PL,v 2.19 2003/01/27 19:03:36 mheins Exp $
+# $Id: makecat.PL,v 2.20 2003/04/10 18:04:24 mheins Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -1337,6 +1337,7 @@
if($ask =~ /^\s*i/i) {
$lm = "i";
+ $Conf{linkmode} = 'INET';
$Inetmode = 1;
my $defport;
@@ -1381,17 +1382,20 @@
$lh = prompt("Link host? ", $default);
redo INETASK if $lh eq '@';
}
+ $Conf{linkport} = $lp;
+ $Conf{linkhost} = $lh;
unlink $prog unless $lh eq $defhost && $lp eq $defport;
} # END INETASK
}
elsif($ask =~ /^\s*n/i) {
- $prog = "NONE";
+ $Conf{linkmode} = $prog = "NONE";
}
else {
$lm = 'u';
+ $Conf{linkmode} = "UNIX";
my $def = -u '/usr/bin/suexec' ? 'y' : 'n';
$ask = prompt("Do you use CGIWRAP or SUEXEC? ", $def);
- $CGIwrap = $ask =~ /^\s*y/i;
+ $Conf{cgiwrap} = $CGIwrap = $ask =~ /^\s*y/i;
}
}
@@ -2294,7 +2298,7 @@
=head1 VERSION
-# $Id: makecat.PL,v 2.19 2003/01/27 19:03:36 mheins Exp $
+# $Id: makecat.PL,v 2.20 2003/04/10 18:04:24 mheins Exp $
=head1 INTRODUCTION
2.16 +4 -0 interchange/dist/foundation/catalog.cfg
rev 2.16, prev_rev 2.15
Index: catalog.cfg
===================================================================
RCS file: /var/cvs/interchange/dist/foundation/catalog.cfg,v
retrieving revision 2.15
retrieving revision 2.16
diff -u -r2.15 -r2.16
--- catalog.cfg 25 Jan 2003 21:24:16 -0000 2.15
+++ catalog.cfg 10 Apr 2003 18:04:24 -0000 2.16
@@ -12,6 +12,10 @@
# Read in initial variables from a database.
VariableDatabase variable
+# Read in site-specific variables from a database (if any).
+# Used to create a information for a transferred catalog
+VariableDatabase site
+
#==========================================================================#
# Allow a template to drop in some beginning config.
2.26 +6 -0 interchange/dist/foundation/products/variable.txt
rev 2.26, prev_rev 2.25
Index: variable.txt
===================================================================
RCS file: /var/cvs/interchange/dist/foundation/products/variable.txt,v
retrieving revision 2.25
retrieving revision 2.26
diff -u -r2.25 -r2.26
--- variable.txt 7 Apr 2003 16:33:32 -0000 2.25
+++ variable.txt 10 Apr 2003 18:04:24 -0000 2.26
@@ -2,6 +2,8 @@
ADDRESS __MVC_ADDRESS__ Company
BAR_LINK_TEMPLATE <A HREF="$URL$" CLASS="barlink">$ANCHOR$</A> Admin colors
CATALOG_STATIC No Static pages
+CGIWRAP __MVC_CGIWRAP__ Admin Control
+CGI_DIR __MVC_CGIDIR__ Admin Control
CGI_URL __MVC_CGIURL__ Directories and Paths
CHECKOUT_MAIL_LIST 1 Mailings
CHECK_ACCEPTED 1 Payment
@@ -21,6 +23,10 @@
FORUM_EMAIL_NOTIFY __MVC_EMAILSERVICE__ Forums
FORUM_PRODUCTS __MVC_MYSQL____MVC_PGSQL__ Forums
IMAGE_DIR __MVC_IMAGEURL__ Directories and Paths
+IC_DIR __MVC_VENDROOT__ Admin Control
+LINKMODE __MVC_LINKMODE__ Admin Control
+LINKHOST __MVC_LINKHOST__ Admin Control
+LINKPORT __MVC_LINKPORT__ Admin Control
LOCALES __MVC_LOCALES__ Internationalization
LOGGED_STATIC 1 Static pages
LOGO __MVC_LOGO__ Template
2.7 +1 -0 interchange/dist/lib/UI/ichelp.txt
rev 2.7, prev_rev 2.6
Index: ichelp.txt
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/ichelp.txt,v
retrieving revision 2.6
retrieving revision 2.7
diff -u -r2.6 -r2.7
--- ichelp.txt 19 Feb 2003 17:01:32 -0000 2.6
+++ ichelp.txt 10 Apr 2003 18:04:24 -0000 2.7
@@ -97,3 +97,4 @@
wizard.tax Wizard : Set Up Tax Information This section helps you to set up your tax information. This information will be entered into Interchange and populated into the Administration tool. This screen is intended only to get you started with tax calculation. It offers a simple calculation method and does not account for multiple delivery locations. The Administration tool allows you to upload tax calculation tables or enter specific tax application rules. The required fields are displayed in bold.<p>The following are descriptions of the fields displayed on the page:<p><table border=1 cellspacing=0 cellpadding=2 width=425><tr><td bgcolor="E0DCE0"><font size=2><b>Field</b></td><td bgcolor="E0DCE0"><font size=2><b>Definition</b></td></tr><tr><td><font size=2>Tax location</td><td><font size=2>The State in which you will be selling your products. If you will be selling in more than one state, enter the primary state. You can make adjustments using the administration tool later.</td></tr><tr><td><font size=2>Tax rate</td><td><font size=2>The percentage that should be used when calculating tax. This is typically the default sales tax for the state you are selling in. If you are unsure of what percentage to use, contact your local Better Business Bureau.</td></tr><tr><td><font size=2>Tax shipping?</td><td><font size=2>If the tax percentage should be applied to the total cost, including shipping. Click the appropriate response from the drop-down menu. Clicking <b>Yes</b> applies the tax after the shipping cost has been added to the order.</td></tr></table>
wizard.ups Wizard : Shipping Configuration for UPS This screen allows you to choose the UPS shipping options that you want to offer. If you are unsure of what a shipping option means, contact UPS for further explaination. The <b>Handling fee</b> allows you to enter a fee for handling the delivery for the customer. Most e-commerce sites charge a handling fee depending on how big or how fragile a product is. This value should be entered in decimal format. For example, if you are charging a handling fee of $3.00, enter 3.00 in the <b>Handling fee</b> field.<p>The Wizard <b>Checklist</b> is displayed on the left. From the checklist you can access any of the Wizard screens. Click <b>Save current settings</b> to save your work to this point.
wizard.verisign Wizard : Signio/Verisign Payment Preferences Enter the values you recieved when you registered for payment processing through Signio/Verisign. If you haven't recieved these values or you haven't signed up for this payment option yet leave these fields blank. Remember that you will not be able to launch your site without a secure payment processing solution. The required fields are displayed in <b>Bold</b>.
+xfer.main Transfer a catalog This function creates a compressed tar file and a suitable restore
script for transferring a catalog from one server or location to
another.
<p>
It will only work properly with a "foundation" style setup with
appropriate variables set properly. These include:
<ul>
<li> SERVER_NAME
<li> SECURE_SERVER
<li> CGI_URL
<li> IMAGE_DIR
<li> SQLDSN
<li> SQLUSER
<li> SQLPASS
<li> DOCROOT
<li> ORDERS_TO
<li> SAMPLEHTML
<li> SAMPLEURL
</ul>
Also, this is designed for Linux systems or other systems with
the GNU utility set. It relies on GNU <tt>tar</tt> and <tt>gzip</tt>.
This only works for the default database, Mysql, and Postgres.
If you are using a SQL database on one DSN defined in <b>SQLDSN</b>, it
will dump the database using the mysqldump or pg_dump utilities; they
must be available in your <b>PATH</b>.
<p>
If you have more than one DSN, it will do the dumps but not create the
restore script for those dumps; that must be done manually.
<p>
It exports all non-Postgres/MySQL database files to text files and does NOT
transfer their associated <tt>.gdbm</tt>, <tt>.db</tt> or <tt>.sql</tt> files.
This may suffice to transfer other SQL databases depending on how they
were defined in the <tt>dbconf/</tt> directory.
<p>
It puts the database dumps and exports in the directory "xfer".
Finally, it creates a tar file named CATALOGNAME.tar.gz, where
CATALOGNAME is equal to IC's name for your catalog.
<p>
To restore the catalog, create the target directory where the
catalog will be, then change directory there and restore the
tar file.
<blockquote>
<PRE>
mkdir -p /var/lib/interchange/newcat
cd /var/lib/interchange/newcat
tar -xzf /tmp/oldcat.tar.gz
</PRE>
</blockquote>
If the directory already exists, move it somewhere else for backup
purposes (or delete it entirely if you are sure it is safe to do so).
<P>
From that directory, inspect the shell script <tt>xfer/restore.sh</tt>
and make app
ate changes; this may include authorization or path information
for the restoring calls to <tt>mysql</tt> or <tt>psql</tt>. Once you have
made any changes, run the shell script:
<blockquote>
<PRE>
cd /var/lib/interchange/newcat
xfer/restore.sh
</PRE>
</blockquote>
You will have to set any permissions separately if the resturing user ID does not
have them.
1.1 interchange/dist/lib/UI/pages/admin/transfer_catalog.html
rev 1.1, prev_rev 1.0
Index: transfer_catalog.html
===================================================================
@_UI_STD_INIT_@
[set page_perm]backup[/set]
[set ui_class]Admin[/set]
[set page_title][L]Transfer Catalog[/L][/set]
[set help_name]xfer.main[/set]
[set icon_name]icon_config.gif[/set]
[calc]
return if $CGI->{do_xfer};
my $old = $Config->{CatalogName};
my $new = $CGI->{rename};
return unless $old and $new;
$new =~ s/[^-\w]+//g;
for(qw/
SERVER_NAME
SECURE_SERVER
CGI_URL
IMAGE_DIR
SQLDSN
SQLUSER
SQLPASS
DOCROOT
ORDERS_TO
SAMPLEHTML
SAMPLEURL
IC_DIR
CGI_DIR
CGIWRAP
LINKMODE
LINKHOST
LINKPORT
/)
{
my $val = $Variable->{$_};
$val =~ s/$old\b/$new/g;
$CGI->{$_} = $val;
}
return;
[/calc]
[if cgi do_xfer]
[tmp xfer_success][xfer-catalog][/tmp]
[/if]
@_UI_STD_HEAD_@
<!-- ----- BEGIN REAL STUFF ----- -->
[if scratch xfer_success]
<span class=cmessage>Catalog output successfully.</span>
[/if]
<table __UI_T_PROPERTIES__>
<tr>
<td colspan=2 class=rborder><img src="bg.gif" width=__UI_MAIN_WIDTH__ height=1></td>
<tr>
<td colspan=2>
<form action="[area @@MV_PAGE@@]" METHOD=POST>
<input type=hidden name=mv_action value="back">
Rename things with current catalog name <b>[calc]$Config->{CatalogName}[/calc]</b> to <input name=rename value="" size=12> <input type=submit value="[L]Rename[/L]">
</form>
</td>
<tr>
<td colspan=2 class=rborder><img src="bg.gif" width=__UI_MAIN_WIDTH__ height=1></td>
</tr>
<FORM ACTION="[area @@MV_PAGE@@]" METHOD=POST>
<input type=hidden name=mv_action value="back">
<input type=hidden name=do_xfer value="1">
<input type=hidden name=rename value="[cgi rename]">
[loop acclist=1 list="SERVER_NAME=Server domain/URL) no leading protocol (www.domain.tld),
SECURE_SERVER=Secure server) with leading protocol (https://www.domain.tld),
CGI_URL=The URL (without server) to call the catalog,
IMAGE_DIR=The image base URL,
SQLDSN=Base SQL DSN (if using SQL),
SQLUSER=SQL user (if any),
SQLPASS=SQL password (if any),
DOCROOT=The HTML document root,
ORDERS_TO=Where orders should be sent,
SAMPLEHTML=Base HTML directory for the catalog (not usually important),
SAMPLEURL=Base static URL for the catalog (not usually important),
IC_DIR=Interchange software directory,
CGI_DIR=CGI directory (where to copy link file)
"]
<tr>
<td align=right>
<b>[loop-code]</b>
</td>
<td>
<input type=text size=60 name="[loop-code]"
value="[filter op=encode_entities interpolate=1][either][cgi [loop-code]][or][var [loop-code]][/either][/filter]"> [loop-param label]
</td>
</tr>
[/loop]
<tr>
<td align=right valign=top>
<b>Link File information<b>
</td>
<td>
[display
name=LINKMODE
cgi-default=1
type=select passed="NONE=NONE (don't try to create one), UNIX=UNIX mode/vlink, INET=INET mode/tlink"
]
Link type
<br>
[display
name=CGIWRAP
cgi-default=1
type=yesno
] Inhibit setuid in UNIX mode (for SUEXEC or CGIWRAP installations)
<br>
[display
name=LINKHOST
cgi-default=1
type=text_20
] Link host if INET mode (default is localhost)
<br>
[display
name=LINKPORT
cgi-default=1
type=text_5
] Link port if INET mode (default is 7786)
</td>
</tr>
<tr>
<td align=right valign=top>
<b>Options<b>
</td>
<td>
<input type=checkbox name="create_db" value=1 [checked cgi=1 name=create_db value=1]>
Create Database on target
<br>
<input type=checkbox name="addcatline" value=1 [checked cgi=1 name=addcatline value=1]>
Add <b>Catalog</b> line to interchange.cfg
<p>
<b><u>Keep files</u></b>
[display
name=keep_together
type=checkbox_left_4
passed="
tmp=Temporary files,
session=Session files,
usertrack=User traffic log,
orders=Order backup files,
survey=Survey log files,
logs=Log files,
backup=Backup files,
config=Original catalog creation files,
upload=Uploads"
cgi-default=1]
</p>
</td>
</tr>
<tr>
<td colspan=2 class=rnorm>
<B>
<INPUT TYPE=submit VALUE="[L]Create Catalog Transfer[/L]">
</B>
</td>
</tr>
<tr>
<td colspan=2 class=rspacer><img src="bg.gif" width=__UI_MAIN_WIDTH__ height=1></td>
</tr>
</FORM>
</table>
<!-- ----- END REAL STUFF ----- -->
@_UI_STD_FOOTER_@
<!-- page: @@MV_PAGE@@ version: $Revision: 1.1 $ -->
1.1 interchange/code/UI_Tag/xfer_catalog.coretag
rev 1.1, prev_rev 1.0
Index: xfer_catalog.coretag
===================================================================
UserTag xfer-catalog Order file
UserTag xfer-catalog addAttr
UserTag xfer-catalog Routine <<EOR
sub {
my ($file, $opt) = @_;
my %dsn;
my %db;
my %export;
my %dbtype;
my %dbname;
my %user;
my %pass;
my $now = time();
my $root = $Vend::Cfg->{VendRoot};
my $catname = $Vend::Cfg->{CatalogName};
my @exclude = ("./$catname.tar.gz", './products/existing.site.txt');
my %exclude = (
tmp => ['./tmp/*'],
session => ['./session/*'],
usertrack => ["./$Vend::Cfg->{TrackFile}"],
orders => ["./logs/tracking.asc", './orders/*'],
survey => ["./logs/survey"],
logs => ['./logs/log', './error.log'],
backup => ['./backup/*'],
config => ['./config/*'],
upload => ['./upload/*'],
);
my $export_and_exclude = sub {
my ($t, $o) = @_;
my $dbo = dbref($t);
$dbo = $dbo->ref() if $dbo;
$export{$t} = $o->{file};
my $dir = $o->{DIR};
my $dbf = $o->{db_file};
if($dbf =~ m{^/}) {
$dbf =~ s{^$root}{.};
}
elsif($dir =~ s{^$root}{.}) {
$dbf = "$dir/$dbf";
}
else {
::logDebug("Unrecognized db file $dbf");
}
push @exclude, $dbf;
};
my @restore = (<<'EOF');
#!/bin/sh
DIR=$1
USAGE="ic_restore.sh [directory]";
if test -n "$DIR"
then
cd $DIR || (echo "$DIR: does not exist"; echo $USAGE; exit 1);
fi
if test ! -d xfer/exports
then
echo "Not a restore directory for Interchange."
echo $USAGE
exit 1;
fi
cp xfer/exports/* products
EOF
my %maptype = (
mysql => {
restore => $::Variable->{RESTORE_COMMAND_MYSQL} || 'mysql',
create => $::Variable->{CREATE_COMMAND_MYSQL} || 'mysqladmin create %s',
command => $::Variable->{DUMP_COMMAND_MYSQL} || 'mysqldump --add-drop-table',
host => '-h %s',
port => '-p %s',
user => '-u %s',
},
Pg => {
restore => $::Variable->{RESTORE_COMMAND_PG} || 'psql -q',
create => $::Variable->{CREATE_COMMAND_PG} || 'createdb %s',
command => $::Variable->{DUMP_COMMAND_PG} || 'pg_dump -c -O',
host => '-h %s',
port => '-p %s',
user => '-U %s',
},
);
my %usermap = (
mysql => {
USER => '-u %s',
PASS => '-p%s',
},
Pg => {
USER => '-U %s',
},
);
my %dbparm = (
mysql => {
database => 1,
},
Pg => {
dbname => 1,
},
);
my $date = POSIX::strftime('%Y%m%d%H%M%S', localtime());
if(-e 'xfer') {
unless($opt->{backup_old}) {
File::Path::rmtree('xfer');
}
else {
rename 'xfer', "xfer.backup.$date";
}
}
File::Path::mkpath('xfer');
File::Path::mkpath('xfer/exports');
File::Path::mkpath('xfer/dumps');
while( my ($t, $o) = each %{$Vend::Cfg->{Database}} ) {
next if $t eq 'site';
#::logDebug("Parsing $t");
if(! $o) {
::logDebug("bad object=$o table=$t");
next;
}
#::logDebug("$t type=$o->{type}");
if($o->{type} != 8) {
$export_and_exclude->($t, $o);
next;
}
my $dsn = $o->{DSN};
#::logDebug("$t DSN=$o->{DSN}");
next if $dsn{$dsn};
my $dbstring = $dsn;
$dbstring =~ s/^dbi://i;
$dbstring =~ s/^(\w+)://i;
my $driver = $1;
#::logDebug("$t driver=$driver");
my $map = $maptype{$driver};
if(! $map) {
$export_and_exclude->($t, $o);
next;
}
$dbtype{$dsn} = $driver;
my $dbname;
my @pieces = split /\s*;\s*/, $dbstring;
my @args;
for(@pieces) {
#::logDebug("checking piece=$_");
if(/=/) {
my ($k, $v) = split /\s*=\s*/, $_;
$k = lc $k;
if(my $tpl = $map->{$k}) {
$tpl =~ s/\%s/$v/g;
push @args, $tpl;
}
elsif($dbparm{$driver}->{$k}) {
$dbname = $v;
}
else {
Vend::Tags->warnings("Unrecognized DSN atom '$_'");
next;
}
}
else {
$dbname = $_;
}
}
if(! $dbname) {
my $msg = "Unable to find dbname for $dsn.";
logError($msg);
return $msg if $opt->{show_error};
return;
}
$dbname{$dsn} = $dbname;
$dsn{$dsn} = join " ", $map->{command}, @args, $dbname;
if (my $user = $o->{USER}) {
$user{$dsn} = $user;
}
if (my $pass = $o->{PASS}) {
$pass{$dsn} = $pass;
}
}
for my $t (keys %export) {
Vend::Data::export_database($t, "$root/xfer/exports/$export{$t}", undef, {})
or logError("Failed to export table $t in xfer-catalog.");
}
for(keys %dsn) {
my $ext = $_ eq $::Variable->{SQLDSN} ? 'maindump' : 'dump';
my $cmd = "$dsn{$_} > xfer/dumps/$dbname{$_}.$dbtype{$_}.$ext";
#::logDebug("executing $cmd");
system $cmd;
if($?) {
my $status = $?;
my $err = $status >> 8;
my $msg = errmsg("error=%s, status=%s execuding dump '%s': %s", $err, $status, $cmd, $!);
::logDebug($msg);
::logError($msg);
return $msg if $opt->{show_error};
return;
}
}
if($opt->{keep_together} ||= $CGI::values{keep_together}) {
my @keys = grep /\w/, split /[\s,\0]+/, $opt->{keep_together};
for(@keys) {
#::logDebug("Setting keepname keep_$_");
$opt->{"keep_$_"} = 1;
}
}
for my $name (keys %exclude) {
my $kname = "keep_$name";
if(exists $opt->{$kname}) {
next if $opt->{$kname};
}
if ($CGI::values{$kname}) {
next;
}
push @exclude, @{$exclude{$name}};
}
my $excludestring = join("\n", @exclude, '');
#::logDebug("exclude:\n$excludestring");
unlink 'exclude-files';
Vend::File::writefile('exclude-files', $excludestring);
my @vars = qw/
CGI_URL
DOCROOT
IMAGE_DIR
ORDERS_TO
SAMPLEHTML
SAMPLEURL
SECURE_SERVER
SERVER_NAME
SQLDSN
SQLPASS
SQLUSER
IC_DIR
CGI_DIR
CGIWRAP
LINKMODE
LINKHOST
LINKPORT
LINKPORT
/;
if(defined $opt->{variables}) {
@vars = grep /\S/, split /[\s,\0+]/, $opt->{variables};
}
my $vdb = dbref('variable');
my @vdb = "code\tVariable\tpref_group";
my $imagebase;
## Don't really care if this fails
rename 'products/site.txt', 'products/existing.site.txt';
my @backups = '.';
my $newdriver;
my %restore;
for(@vars) {
my $val = $CGI::values{$_} || $::Variable->{$_};
my $pref = $val, tag_data('variable', 'pref_group', $_);
push @vdb, join("\t", $_, $val, $pref);
if($_ eq 'SQLDSN') {
my $thing = $restore{sqldsn} = $val;
$thing =~ s/^dbi:(\w+)://i
and $newdriver = $1;
if($thing =~ /\bdatabase=(\w+)/ or $thing =~ /\bdbname=(\w+)/) {
$thing = $1;
}
$restore{dbname} = $thing;
}
elsif($_ eq 'DOCROOT') {
$restore{docroot} = $val;
$imagebase = $val if $val;
}
elsif($_ eq 'IMAGE_DIR') {
my $add = $val;
if($add =~ m{^http:}) {
undef $imagebase;
}
else {
$add =~ s{^/\~[^/]+}{};
$imagebase .= $add if $imagebase;
}
}
else {
$restore{lc $_} = $val;
}
}
#::logDebug("imagebase=$imagebase");
RESTOREBUILD: {
if($imagebase) {
push @backups, './images/*';
push @restore, <<EOF;
mkdir -p $imagebase
cp -r images/* $imagebase
rm -rf images
ln -s $imagebase images
EOF
}
last RESTOREBUILD unless $newdriver;
my @possible = glob('xfer/dumps/*.maindump');
if(@possible) {
my $m = $maptype{$newdriver}
or last RESTOREBUILD;
if(! $opt->{restore_command}) {
$opt->{restore_command} = $m->{restore}
or last RESTOREBUILD;
if($restore{sqluser}) {
my $tpl = $m->{user};
$tpl =~ s/\%s/$restore{sqluser}/g
and $opt->{restore_command} .= " $tpl";
}
if($restore{sqlpass}) {
my $tpl = $m->{pass};
$tpl =~ s/\%s/$restore{sqlpass}/g
and $opt->{restore_command} .= " $tpl";
}
$opt->{restore_command} .= ' %s';
$opt->{restore_command} .= ' < %f';
}
if($opt->{create_db} || $CGI::values{create_db}) {
$opt->{create_command} ||= $m->{create};
$opt->{create_command} =~ s/\%s/$restore{dbname}/g;
$opt->{create_command} .= ' 2> /dev/null'
unless $opt->{create_command} =~ /2\s*>/;
push @restore, $opt->{create_command};
}
else {
undef $opt->{create_command};
}
$opt->{restore_command} =~ s/\%s/$restore{dbname}/g;
$opt->{restore_command} =~ s/\%f/$possible[0]/g;
push @restore, $opt->{restore_command};
}
else {
undef $opt->{create_command};
undef $opt->{restore_command};
}
}
my $did_link;
my $did_catline;
RESTORECGI: {
last RESTORECGI if $restore{linkmode} =~ /none/i;
my $dest = $restore{cgi_dir};
my $progname = $restore{cgi_url};
$progname =~ s:.*/::;
$dest .= "/$progname";
my @args = "$restore{ic_dir}/bin/compile_link";
if($restore{linkmode} =~ /^u/i) {
push @args, '-u';
push @args, '-nosuid' if $restore{cgiwrap};
}
else {
push @args, '-i';
push @args, "-h $restore{linkhost}" if $restore{linkhost};
push @args, "-p $restore{linkport}" if $restore{linkport};
}
push @args, "-o $dest";
my $cstring = join " ", @args;
push @restore, "\n$cstring\n";
$did_link = 1;
}
my $newname = $CGI::values{rename} || $catname;
$restore{newname} = $newname;
ADDCATLINE: {
last ADDCATLINE unless $opt->{addcatline} ||= $CGI::values{addcatline};
$restore{perl} = $^X;
my $script = <<'EOScript';
#!__PERL__
use File::Copy;
use Cwd;
my $vendroot = '__IC_DIR__';
my $catalogname = '__NEWNAME__';
my $cgiurl = '__CGI_URL__';
my $aliases = '__CGI_ALIASES__';
my $targfile = "$vendroot/interchange.cfg";
unless ($vendroot and $catalogname and $cgiurl) {
die "xfer/modic_cfg.pl: Not all information necessary to add Catalog line.\n";
}
my $cur = cwd();
my $newcfgline = sprintf "%-10s %s %s %s %s\n", 'Catalog',
$catalogname, $cur, $cgiurl, $aliases;
my ($mark, @out);
my $tmpfile;
$tmpfile= "$targfile.$$";
if (-f $targfile) {
File::Copy::copy ($targfile, $tmpfile)
or die "\nCouldn't copy $targfile: $!\n";
}
else {
my @cf = ("$targfile.dist", "$vendroot/interchange.cfg.dist");
my $cf;
for(@cf) {
$cf = $_ if -f $_;
}
File::Copy::copy($cf, $tmpfile)
or die "\nCouldn't copy $cf: $!\n";
}
open(CFG, "< $tmpfile")
or die "\nCouldn't open $tmpfile: $!\n";
while(<CFG>) {
$mark = $. if /^#?catalog\s+/i;
print "\nDeleting old configuration $catalogname.\n"
if s/^(catalog\s+$catalogname\s+)/#$1/io;
push @out, $_;
}
close CFG;
if ($targfile) {
open(NEWCFG, ">$targfile")
or die "\nCouldn't write $targfile: $!\n";
} else {
open(NEWCFG, ">$targfile")
or die "\nCouldn't write $targfile: $!\n";
}
$newcfgline = sprintf "%-13s %s %s %s %s\n", 'Catalog',
$catalogname, $cur, $cgiurl, $aliases;
if (defined $mark) {
print NEWCFG @out[0..$mark-1];
print NEWCFG $newcfgline;
print NEWCFG @out[$mark..$#out];
}
else {
print "\nNo catalog previously defined. Adding $catalogname at top.\n";
print NEWCFG $newcfgline;
print NEWCFG @out;
}
close NEWCFG || die "close: $!\n";
unlink $tmpfile;
EOScript
$script =~ s/__([A-Z]\w+?)__/$restore{lc $1}/eg;
Vend::File::writefile('>xfer/addcatline.pl', $script );
push @restore, "\nperl xfer/addcatline.pl\n";
$did_catline = 1;
}
my $finmsg = <<EOThis;
Finished the restore script.
You should inspect the output above (if any) in case of errors.
EOThis
$finmsg .= <<EOThis unless $did_catline;
You will need to add the following line to interchange.cfg if
you haven't done so already:
Catalog $newname \$CURDIR $restore{cgi_url}
EOThis
$finmsg .= <<EOThis unless $did_link;
You will also need to copy an appropriate link program if it is
not already in place.
EOThis
push @restore, <<EOThis;
CURDIR=`pwd`
cat <<EOF
$finmsg
And of course you need to restart Interchange.
EOF
EOThis
Vend::File::writefile('>xfer/restore.sh', join ("\n", @restore, '') );
Vend::File::writefile('>products/site.txt', join("\n", @vdb, ""));
chmod 0755, 'xfer/restore.sh';
my $fstring = join " ", @backups;
my $cmdstring = "tar -X exclude-files -c -z -f $catname.tar.gz .";
#::logDebug("executing $cmdstring");
eval {
system $cmdstring;
};
## Don't really care if this fails
unlink 'products/site.txt';
rename 'products/existing.site.txt', 'products/site.txt';
if($?) {
my $status = $?;
my $err = $status >> 8;
my $msg = errmsg("error=%s, status=%s executing dump '%s': %s", $err, $status, $cmdstring, $!);
::logDebug($msg);
::logError($msg);
return $msg if $opt->{show_error};
return;
}
#return join("\n###\n", ::uneval(\%dsn), ::uneval(\%export), $excludestring);
return 1;
}
EOR
1.2 +14 -12 interchange/dist/lib/UI/pages/include/menus/MiscFunction.txt
rev 1.2, prev_rev 1.1
Index: MiscFunction.txt
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/pages/include/menus/MiscFunction.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MiscFunction.txt 14 Jan 2003 14:35:56 -0000 1.1
+++ MiscFunction.txt 10 Apr 2003 18:04:24 -0000 1.2
@@ -4,15 +4,17 @@
003 x003 admin/file_transfer initial_dir=images Upload/Download Images 0 File transfer tool starting in images directory
004 x004 admin/file_transfer initial_dir=session&find_session=1 Search for sessions 0 File transfer tool starting in session directory
005 x005 admin/file_transfer initial_dir=. General File Transfer 0 Start transferring from catalog root
-006 x006 Legacy Tools 0
-007 x007 admin/layout Layout Editor 0 Organize categories with area and cat tables
-008 x008 admin/layout_auto Layout Editor Auto-populate 0 Automatically populate area and cat tables from product data
-009 x009 ITL Helpers 0
-010 x010 admin/search_wizard Search Wizard 0 Generate a search for a page
-011 x011 admin/button_builder Button Builder 0 Generate an order button or link
-012 x012 admin/test_code Test code 1 0 Test snippets of ITL
-013 x013 Encryption 1 0
-014 x014 admin/gpg_key Add GPG Key 1 0 Check and add GPG keys to keyring
-015 x015 admin/pref_select ui_text_qualification=pref_group=Encryption Encryption Preferences 1 0
-016 x016 Upgrade Helpers 0
-017 x017 admin/merge_meta Merge metadata 0 Merge new metadata values from upgraded Interchange version
+006 x006 Backup Functions 0
+007 x007 admin/transfer_catalog Create catalog tar file 0 Create a tar file of the catalog suitable for transferring to other systems
+008 x008 Legacy Tools 0
+009 x009 admin/layout Layout Editor 0 Organize categories with area and cat tables
+010 x010 admin/layout_auto Layout Editor Auto-populate 0 Automatically populate area and cat tables from product data
+011 x011 ITL Helpers 0
+012 x012 admin/search_wizard Search Wizard 0 Generate a search for a page
+013 x013 admin/button_builder Button Builder 0 Generate an order button or link
+014 x014 admin/test_code Test code 1 0 Test snippets of ITL
+015 x015 Encryption 1 0
+016 x016 admin/gpg_key Add GPG Key 1 0 Check and add GPG keys to keyring
+017 x017 admin/pref_select ui_text_qualification=pref_group=Encryption Encryption Preferences 1 0
+018 x018 Upgrade Helpers 0
+019 x019 admin/merge_meta Merge metadata 0 Merge new metadata values from upgraded Interchange version