diff --git a/setup/unattended-install/unattended-install.php b/setup/unattended-install/unattended-install.php index cde9ff0846..4151318add 100644 --- a/setup/unattended-install/unattended-install.php +++ b/setup/unattended-install/unattended-install.php @@ -143,6 +143,8 @@ function PrintUsageAndExit() $sDBPwd = $aDBXmlSettings['pwd']; $sDBName = $aDBXmlSettings['name']; $sDBPrefix = $aDBXmlSettings['prefix']; +$bDBTlsEnabled = $aDBXmlSettings['db_tls_enabled']; +$sDBTlsCa = $aDBXmlSettings['db_tls_ca']; if ($sMode == 'install') { @@ -219,13 +221,10 @@ function PrintUsageAndExit() die("Cleanup not implemented for a partial database (prefix= '$sDBPrefix')\nExiting."); } - $oMysqli = new mysqli($sDBServer, $sDBUser, $sDBPwd); - if ($oMysqli->connect_errno) - { - die("Cannot connect to the MySQL server (".$oMysqli->connect_errno . ") ".$oMysqli->connect_error."\nExiting"); - } - else + try { + $oMysqli = CMDBSource::GetMysqliInstance($sDBServer, $sDBUser, $sDBPwd, null, $bDBTlsEnabled, $sDBTlsCa, true); + if ($oMysqli->select_db($sDBName)) { echo "Deleting database '$sDBName'\n"; @@ -236,6 +235,10 @@ function PrintUsageAndExit() echo "The database '$sDBName' does not seem to exist. Nothing to cleanup.\n"; } } + catch (MySQLException $e) + { + die($e->getMessage()."\nExiting"); + } } } else @@ -312,9 +315,9 @@ function PrintUsageAndExit() } else { - $oMysqli = new mysqli($sDBServer, $sDBUser, $sDBPwd); - if (!$oMysqli->connect_errno) + try { + $oMysqli = CMDBSource::GetMysqliInstance($sDBServer, $sDBUser, $sDBPwd, null, $bDBTlsEnabled, $sDBTlsCa, true); if ($oMysqli->select_db($sDBName)) { // Check the presence of a table to record information about the MTP (from the Designer) @@ -357,6 +360,10 @@ function PrintUsageAndExit() } } } + catch (MySQLException $e) + { + // Continue anyway + } } } else