Commit 2434516a authored by Robert Ricci's avatar Robert Ricci

New script: export_tables . Simply spits to stdout a set of SQL

commands to fill a few tables that should be common across most
sites, so that this data can be distributed to them.

The simple single-column table exported_tables controls which tables
are output.
parent a408a3b1
......@@ -1124,7 +1124,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:1127: checking for a BSD compatible install" >&5
echo "configure:1128: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -1237,7 +1237,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
tmcd/tmcd.restart \
utils/GNUmakefile utils/vlandiff utils/vlansync utils/delay_config \
utils/sshtb utils/create_image utils/node_admin utils/webcreateimage \
utils/firstuser \
utils/firstuser utils/export_tables\
www/GNUmakefile www/defs.php3 www/dbdefs.php3 \
vis/GNUmakefile vis/vistopology vis/webvistopology vis/top2gif \
vis/dbvistopology vis/dbtopper \
......
......@@ -309,7 +309,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
tmcd/tmcd.restart \
utils/GNUmakefile utils/vlandiff utils/vlansync utils/delay_config \
utils/sshtb utils/create_image utils/node_admin utils/webcreateimage \
utils/firstuser \
utils/firstuser utils/export_tables\
www/GNUmakefile www/defs.php3 www/dbdefs.php3 \
vis/GNUmakefile vis/vistopology vis/webvistopology vis/top2gif \
vis/dbvistopology vis/dbtopper \
......
......@@ -188,6 +188,15 @@ CREATE TABLE experiments (
PRIMARY KEY (eid,pid)
) TYPE=MyISAM;
#
# Table structure for table 'exported_tables'
#
CREATE TABLE exported_tables (
table_name varchar(64) NOT NULL default '',
PRIMARY KEY (table_name)
) TYPE=MyISAM;
#
# Table structure for table 'exppid_access'
#
......
......@@ -10,7 +10,7 @@ UNIFIED = @UNIFIED_BOSS_AND_OPS@
include $(OBJDIR)/Makeconf
BIN_SCRIPTS = delay_config sshtb create_image node_admin
SBIN_SCRIPTS = vlandiff vlansync withadminprivs
SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables
LIBEXEC_SCRIPTS = webcreateimage
#
......
#!/usr/bin/perl -w
#
# export_tables - Create an SQL file with the contents of selected tables
# that should more or less be the same across all sites.
#
use English;
#
# Configure variables
#
use lib '@prefix@/lib';
use libdb;
my $DBNAME = '@TBDBNAME@';
my $mysqldump = "mysqldump";
if (!TBAdmin($UID)) {
die("Only admins get to use this program\n");
}
#
# Build a list of tables to export
#
my $result = DBQueryFatal("select table_name from exported_tables");
my $table_names;
while (my ($table_name) = $result->fetchrow()) {
$table_names .= "$table_name ";
}
#
# Run mysqldump, and read its stdout
#
open(FH,"$mysqldump -t $DBNAME $table_names |") or
die "Unable to run $mysqldump: $!\n";
#
# Change INSERT to REPLACE, so that the resulting SQL can be used to update
# existing databases.
#
while (<FH>) {
s/^INSERT/REPLACE/g;
print;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment