Commit 1c73648a authored by Mike Hibler's avatar Mike Hibler
Browse files

Some install tweaks for mysql 5.7.

parent 629f2f0b
#!/usr/bin/perl -w
#
# Copyright (c) 2003-2016 University of Utah and the Flux Group.
# Copyright (c) 2003-2017 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -321,6 +321,7 @@ $TBOPSEMAIL = "@TBOPSEMAIL@";
$TBTESTSUITEEMAIL = "@TBTESTSUITEEMAIL@";
# For installing mysqld
$MYSQLD = "/usr/local/libexec/mysqld";
$MYSQLADMIN = "/usr/local/bin/mysqladmin";
$MYSQLSHOW = "/usr/local/bin/mysqlshow";
$MYSQLDUMP = "/usr/local/bin/mysqldump";
......
......@@ -8,18 +8,37 @@ use installvars;
sub Install($$$)
{
my ($server, $isupdate, $impotent) = @_;
my $newmysql = 0;
# Replace if this script does an update for ip/domain.
return 0
if ($isupdate);
Phase "database", "Setting up database", sub {
# Find out what version is installed
Phase "version", "Determine mysqld version", sub {
PhaseFail("Mysql not installed")
if (! -x "$MYSQLADMIN");
my $v = `$MYSQLADMIN -V`;
if ($v =~ /Distrib (\d+)\.(\d+)\.(\d+)/) {
($vmaj,$vmin,$vrel) = ($1,$2,$3);
if ($vmaj > 5 ||
($vmaj == 5 && $vmin > 7) ||
($vmaj == 5 && $vmin == 7 && $vrel >= 6)) {
$newmysql = 1;
}
}
};
Phase "initialize", "Initializing mysql", sub {
PhaseSkip("mysqld already initialzed")
if (-d "$MYSQLDBDIR/mysql");
ExecQuietFatal("$MYSQLINSTALL --ldata=${MYSQLDBDIR} --basedir=/usr/local");
ExecQuietFatal("$CHOWN -R mysql:mysql $MYSQLDBDIR");
if ($newmysql) {
ExecQuietFatal("$MYSQLD --initialize-insecure --user=mysql --datadir=${MYSQLDBDIR} --basedir=/usr/local");
} else {
ExecQuietFatal("$MYSQLINSTALL --ldata=${MYSQLDBDIR} --basedir=/usr/local");
ExecQuietFatal("$CHOWN -R mysql:mysql $MYSQLDBDIR");
}
};
Phase "mysql", "Starting mysqld", sub {
if (!ExecQuiet("$MYSQLADMIN ping")) {
......
......@@ -5,9 +5,12 @@ use strict;
use libinstall;
use installvars;
my ($vmaj,$vmin,$vrel) = (0, 0, 0);
sub Install($$$)
{
my ($server, $isupdate, $impotent) = @_;
my $newmysql = 0;
# Replace if this script does an update for ip/domain.
return 0
......@@ -17,6 +20,21 @@ sub Install($$$)
PhaseSkip("mysqld not supported on ops")
if ($FBSD_MAJOR == 4);
# Find out what version is installed
Phase "version", "Determine mysqld version", sub {
PhaseFail("Mysql not installed")
if (! -x "$MYSQLADMIN");
my $v = `$MYSQLADMIN -V`;
if ($v =~ /Distrib (\d+)\.(\d+)\.(\d+)/) {
($vmaj,$vmin,$vrel) = ($1,$2,$3);
if ($vmaj > 5 ||
($vmaj == 5 && $vmin > 7) ||
($vmaj == 5 && $vmin == 7 && $vrel >= 6)) {
$newmysql = 1;
}
}
};
# Get a password for the the DB.
Phase "password", "Asking for mysqld root password", sub {
DoneIfExists("$ETCDIR/mysqld.pwd");
......@@ -42,12 +60,17 @@ sub Install($$$)
PhaseSkip("mysqld already initialzed")
if (-d "$MYSQLDBDIR/mysql");
ExecQuietFatal("$MYSQLINSTALL --ldata=${MYSQLDBDIR} --basedir=/usr/local");
ExecQuietFatal("$CHOWN -R mysql:mysql $MYSQLDBDIR");
if ($newmysql) {
ExecQuietFatal("$MYSQLD --initialize-insecure --user=mysql --datadir=${MYSQLDBDIR} --basedir=/usr/local");
} else {
ExecQuietFatal("$MYSQLINSTALL --ldata=${MYSQLDBDIR} --basedir=/usr/local");
ExecQuietFatal("$CHOWN -R mysql:mysql $MYSQLDBDIR");
}
};
Phase "start", "Starting mysqld", sub {
my ($exitval) = ExecQuiet("$MYSQLADMIN -u mysql ping");
my $user = ($newmysql ? "root" : "mysql");
my ($exitval) = ExecQuiet("$MYSQLADMIN -u $user ping");
PhaseSkip("mysqld already running")
if ($exitval == 0);
......@@ -55,9 +78,9 @@ sub Install($$$)
ExecQuietFatal("$RCDIR/1.mysql-server.sh start");
# Give mysqld some time to start, then make sure it did
sleep 5;
if (ExecQuiet("$MYSQLADMIN -u mysql ping")) {
if (ExecQuiet("$MYSQLADMIN -u $user ping")) {
sleep 10;
ExecQuietFatal("$MYSQLADMIN -u mysql ping");
ExecQuietFatal("$MYSQLADMIN -u $user ping");
}
};
......@@ -70,11 +93,19 @@ sub Install($$$)
if ($exitval) {
PhaseSkip("Privs already initialized");
}
($exitval, @rows) =
ExecQuietFatal("echo \"update user set ".
" Password=PASSWORD($password) ".
"where user='root'; flush privileges\" | ".
"$MYSQL -s -u root mysql");
if ($newmysql) {
($exitval, @rows) =
ExecQuietFatal("echo \"alter user 'root'\@'localhost' ".
"identified by $password; ".
"flush privileges\" | ".
"$MYSQL -s -u root mysql");
} else {
($exitval, @rows) =
ExecQuietFatal("echo \"update user set ".
" Password=PASSWORD($password) ".
"where user='root'; flush privileges\" | ".
"$MYSQL -s -u root mysql");
}
};
Phase "dbpatch", "Patching up mysql DB", sub {
......
Supports Markdown
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