Commit be7f6105 authored by Leigh Stoller's avatar Leigh Stoller

Initialize the version_info table by looking at the highest numbered

update file in each of the sql and install update dirs.
parent 157d3802
......@@ -21,8 +21,6 @@
#
my $PREFIX = '@prefix@';
my $SRCDIR = '@srcdir@';
my $TOP_SRCDIR = '@top_srcdir@';
my $DBNAME = "@TBDBNAME@";
my $ERRORLOG_DBNAME = "@TBERRORLOGDBNAME@";
my $ELABINELAB = @ELABINELAB@;
my $WINSUPPORT = @WINSUPPORT@;
......@@ -79,7 +77,6 @@ my $MOUNT = "/sbin/mount";
my $SUDO = "/usr/local/bin/sudo";
my $SUIDPERL = "/usr/bin/suidperl";
my $MYSQL = "/usr/local/bin/mysql";
my $MYSQLADMIN = "/usr/local/bin/mysqladmin";
my $MYSQLSHOW = "/usr/local/bin/mysqlshow";
my $MYSQLDUMP = "/usr/local/bin/mysqldump";
......@@ -946,6 +943,46 @@ Phase "database", "Setting up database", sub {
}
ExecQuietFatal("$MYSQL $ERRORLOG_DBNAME < $TOP_SRCDIR/sql/database-create-errorlog.sql");
};
Phase "version_info", "Initializing version_info table", sub {
my $SQLUPDATES =
"$TOP_SRCDIR/sql/updates/$SQL_UPDATE_MAJOR_REVISION";
my $INUPDATES =
"$TOP_SRCDIR/install/updates/$INSTALL_UPDATE_MAJOR_REVISION";
my ($exitval, @results) =
ExecQuiet("echo 'select * from version_info' | $MYSQL -s $DBNAME");
if ($exitval) {
PhaseFail("Error running query");
}
if (scalar(@results)) {
PhaseSkip("Already done");
}
($exitval, @results) =
ExecQuiet("cd $SQLUPDATES ; ls | sort -n -r | head -1");
if ($exitval) {
PhaseFail("Error getting sql update list");
}
my $sqlfile = $results[0];
chomp($sqlfile);
($exitval, @results) =
ExecQuiet("cd $INUPDATES ; ls | sort -n -r | head -1");
if ($exitval) {
PhaseFail("Error getting install update list");
}
my $updatefile = $results[0];
chomp($updatefile);
my $sqlval = $SQL_UPDATE_MAJOR_REVISION . "." . $sqlfile;
my $upval = $INSTALL_UPDATE_MAJOR_REVISION . "." . $updatefile;
ExecQuietFatal("echo 'insert into version_info set ".
" name=\"dbrev\", value=\"$sqlval\"' ".
"| $MYSQL -s $DBNAME");
ExecQuietFatal("echo 'insert into version_info set ".
" name=\"install\", value=\"$upval\"' ".
"| $MYSQL -s $DBNAME");
};
};
Phase "rc.conf", "Adding testbed content to $RCCONF", sub {
......
......@@ -18,7 +18,6 @@
# Configure variables
#
my $PREFIX = '@prefix@';
my $TOP_SRCDIR = '@top_srcdir@';
my $OURDOMAIN = '@OURDOMAIN@';
my $USERNODE = '@USERNODE@';
......
......@@ -10,17 +10,20 @@
#
use POSIX qw(strftime);
use Exporter;
use vars qw(@EXPORT $TOP_OBJDIR
use vars qw(@EXPORT $TOP_OBJDIR $TOP_SRCDIR
$TBROOT $LOGDIR $MAINSITE $PGENISUPPORT $GMAKE $PKG_INFO
$PORTSDIR $VARRUN $RCDIR);
$PORTSDIR $VARRUN $RCDIR $MYSQL $DBNAME
$SQL_UPDATE_MAJOR_REVISION $INSTALL_UPDATE_MAJOR_REVISION);
@EXPORT = qw($TOP_OBJDIR
@EXPORT = qw($TOP_OBJDIR $TOP_SRCDIR
$TBROOT $LOGDIR $MAINSITE $PGENISUPPORT $GMAKE $PKG_INFO
$PORTSDIR $VARRUN $RCDIR);
$PORTSDIR $VARRUN $RCDIR $MYSQL $DBNAME
$SQL_UPDATE_MAJOR_REVISION $INSTALL_UPDATE_MAJOR_REVISION);
# Configure variables
$TBROOT = "@prefix@";
$TOP_SRCDIR = "@top_srcdir@";
$LOGDIR = "$TBROOT/log";
$MAINSITE = @TBMAINSITE@;
$PGENISUPPORT = @PROTOGENI_SUPPORT@;
......@@ -30,6 +33,14 @@ $PORTSDIR = "/usr/ports";
$VARRUN = "/var/run";
$RCDIR = "/usr/local/etc/rc.d";
$DBNAME = "@TBDBNAME@";
$MYSQL = "/usr/local/bin/mysql";
# Change these if the major numbers in sql/updates or install/updates
# are changed.
$SQL_UPDATE_MAJOR_REVISION = 4;
$INSTALL_UPDATE_MAJOR_REVISION = 5;
#
# Make sure that output gets printed right away
#
......@@ -38,7 +49,7 @@ $| = 1;
#
# Magic string that shows up in files already edited
#
my $MAGIC_TESTBED_VERSION = "5.0";
my $MAGIC_TESTBED_VERSION = $INSTALL_UPDATE_MAJOR_REVISION + ".0";
my $MAGIC_TESTBED_START = "Added by Emulab - Version: ";
my $MAGIC_TESTBED_END = "End of Emulab added section";
......
......@@ -218,7 +218,6 @@ my $HTTPD_CONF = "$APACHE_ETCDIR/httpd.conf";
my $WWWDIR = "/usr/local/www/data";
# For installing mysqld
my $MYSQL = "/usr/local/bin/mysql";
my $MYSQLADMIN = "/usr/local/bin/mysqladmin";
my $MYSQLSHOW = "/usr/local/bin/mysqlshow";
my $MYSQLDUMP = "/usr/local/bin/mysqldump";
......@@ -233,7 +232,6 @@ my $LIST_DIR = "/etc/mail/lists";
my $TIPLOG_DIR = "/var/log/tiplogs";
my $PORTSMISCDIR = "$PORTSDIR/misc";
my $SRCDIR = '@srcdir@';
my $TOP_SRCDIR = "@top_srcdir@";
#
# And some lists that we use
......
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