diff --git a/configure b/configure index 1a0b8d7eaec7282923e7a8a95c12bec948b07af9..b8b10680b0040ce00a59e4db9e155303bccbf5bd 100755 --- a/configure +++ b/configure @@ -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 \ diff --git a/configure.in b/configure.in index 2367f2d3f16466cc8237a1b676ea40798c96d560..7b47375979c9bfdd3249dce57ee3d759a704a8e0 100755 --- a/configure.in +++ b/configure.in @@ -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 \ diff --git a/sql/database-create.sql b/sql/database-create.sql index 1aded4da9e58e62ceba5d4d3ad8ae87d05f9306b..f4adccfa369d052cf618f95c2002a757db5b89e0 100644 --- a/sql/database-create.sql +++ b/sql/database-create.sql @@ -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' # diff --git a/utils/GNUmakefile.in b/utils/GNUmakefile.in index de7e2cb97124872ef7cfc4b3287a01dc2989934b..c61315fda6a7611be4d34f01a84cd7e961ed87a5 100644 --- a/utils/GNUmakefile.in +++ b/utils/GNUmakefile.in @@ -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 # diff --git a/utils/export_tables.in b/utils/export_tables.in new file mode 100755 index 0000000000000000000000000000000000000000..24453a5050c543cf6e5d3cbff229f886b6a2dfea --- /dev/null +++ b/utils/export_tables.in @@ -0,0 +1,44 @@ +#!/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; +}