mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
feature: support non-standard unix socket (#5724)
* Add support for custom MySQL unix-socket * NULL must be lowercase! * Naive edit of html/install.php * fixup * Refactor dbConnect Use it everywhere * $config needs to be global Don't need to set $database_link * small cleanups
This commit is contained in:
committed by
Neil Lathwood
parent
66d9d54f73
commit
b1a414e785
@@ -27,6 +27,8 @@
|
||||
* @param array $modules Which modules to initialize
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
$install_dir = realpath(__DIR__ . '/..');
|
||||
$config['install_dir'] = $install_dir;
|
||||
chdir($install_dir);
|
||||
@@ -103,20 +105,16 @@ if ($config['memcached']['enable'] === true) {
|
||||
|
||||
if (!module_selected('nodb', $init_modules)) {
|
||||
// Connect to database
|
||||
$database_link = mysqli_connect('p:' . $config['db_host'], $config['db_user'], $config['db_pass'], null, $config['db_port']);
|
||||
if (!$database_link) {
|
||||
echo '<h2>MySQL Error</h2>';
|
||||
echo mysqli_connect_error();
|
||||
die;
|
||||
try {
|
||||
dbConnect();
|
||||
} catch (\LibreNMS\Exceptions\DatabaseConnectException $e) {
|
||||
if (isCli()) {
|
||||
echo 'MySQL Error: ' . $e->getMessage() . PHP_EOL;
|
||||
} else {
|
||||
echo "<h2>MySQL Error</h2><p>" . $e->getMessage() . "</p>";
|
||||
}
|
||||
exit(2);
|
||||
}
|
||||
$database_db = mysqli_select_db($database_link, $config['db_name']);
|
||||
if (!$database_db) {
|
||||
mysqli_query($database_link, "CREATE DATABASE " . $config['db_name'] . " CHARACTER SET utf8 COLLATE utf8_unicode_ci");
|
||||
$database_db = mysqli_select_db($database_link, $config['db_name']);
|
||||
}
|
||||
dbQuery("SET NAMES 'utf8'");
|
||||
dbQuery("SET CHARACTER SET 'utf8'");
|
||||
dbQuery("SET COLLATION_CONNECTION = 'utf8_unicode_ci'");
|
||||
|
||||
// pull in the database config settings
|
||||
mergedb();
|
||||
|
||||
Reference in New Issue
Block a user