Skip to content

Commit

Permalink
Make sanity check smarter
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed May 21, 2024
1 parent 4d4616b commit 88a0327
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions admin/sanity-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
$msg = $ex->getMessage();
error_log("DB connection: ".$msg);
echo('<div class="alert alert-danger" style="margin: 10px;">'."\n");
echo("<p>Database error detail: ".$msg."</p>\n");
if ( strpos($msg, 'Unknown database') !== false ||
strpos($msg, 'Access denied for user') !== false ) {
echo("<p>An error has occurred. Either your database has
Expand All @@ -18,13 +19,15 @@
<p>If you have full access to your MySql instance (i.e. like
MAMP or XAMPP, you may need to run commands like this:</p>
<pre>
USE mysql;
CREATE DATABASE tsugi DEFAULT CHARACTER SET utf8;
CREATE USER 'ltiuser'@'localhost' IDENTIFIED BY 'ltipassword';
GRANT ALL ON tsugi.* TO 'ltiuser'@'localhost';
CREATE USER 'ltiuser'@'127.0.0.1' IDENTIFIED BY 'ltipassword';
FLUSH PRIVILEGES;
USE tsugi;
GRANT ALL ON tsugi.* TO 'ltiuser'@'localhost';
GRANT ALL ON tsugi.* TO 'ltiuser'@'127.0.0.1';
</pre>
<p>Note: MySQL 8.0 may require different commands.</p>
<p>Make sure to choose appropriate passwords when setting this up.</p>
<p>If you are running in a hosted environment and are using an admin tool like
CPanel (or equivalent). You must user this interface to create a database,
Expand Down Expand Up @@ -69,16 +72,14 @@
this is usually moved to port 8889. If neither 3306 nor 8889 works you
probably have a bad host name. Or talk to your system administrator.
</p>
<p>Note: Tsugi works best with MySQL 5.x. Some of the setup and commands may need
to be different for MySQL 8.0.
<p>Note: Tsugi works best with MySQL 8.x.
</p>
');
} else {
echo("<p>There is a problem with your database connection.</p>\n");
echo("<p>Tsugi works best with MySQL 5.x.</p>\n");
echo("<p>Tsugi works best with MySQL 8.x.</p>\n");
}

echo("<p>Database error detail: ".$msg."</p>\n");
echo("<p>Once you have fixed the problem, come back to this page and refresh
to see if this message goes away.</p>");
echo('<p>Installation instructions are avaiable at <a href="http://www.tsugi.org/"
Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
header('Content-Type: text/html; charset=utf-8');
session_start();

require_once("admin/sanity-db.php");

if ( $PDOX !== false ) LTIX::loginSecureCookie();

$OUTPUT->header();
$OUTPUT->bodyStart();

require_once("admin/sanity-db.php");
$OUTPUT->topNav();
$OUTPUT->flashMessages();
?>
Expand Down

0 comments on commit 88a0327

Please sign in to comment.