Updated all images with pgsql compatibility #42

This commit is contained in:
Llewellyn van der Merwe 2023-03-31 15:09:56 +02:00
parent 84876534d1
commit cf7f1e8d33
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
18 changed files with 702 additions and 225 deletions

View File

@ -120,7 +120,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi fi
# Ensure the MySQL Database is created # Ensure the MySQL Database is created
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" "${JOOMLA_DB_TYPE:-mysqli}"
echo >&2 "========================================================================" echo >&2 "========================================================================"
echo >&2 echo >&2

View File

@ -1,5 +1,5 @@
<?php <?php
// Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME" // Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME", 5 => "$JOOMLA_DB_TYPE"
$stderr = fopen('php://stderr', 'w'); $stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nEnsuring Joomla database is present\n"); fwrite($stderr, "\nEnsuring Joomla database is present\n");
@ -10,40 +10,93 @@ if (strpos($argv[1], ':') !== false)
else else
{ {
$host = $argv[1]; $host = $argv[1];
$port = 3306; $port = null;
} }
$maxTries = 10; $user = $argv[2];
$password = $argv[3];
$db = $argv[4];
$dbType = strtolower($argv[5]);
// set original default behaviour for PHP 8.1 and higher if ($dbType === 'mysqli')
// see https://www.php.net/manual/en/mysqli-driver.report-mode.php
mysqli_report(MYSQLI_REPORT_OFF);
do
{ {
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port); $port = $port ? (int)$port : 3306;
$maxTries = 10;
if ($mysql->connect_error) // set original default behaviour for PHP 8.1 and higher
{ // see https://www.php.net/manual/en/mysqli-driver.report-mode.php
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n"); mysqli_report(MYSQLI_REPORT_OFF);
--$maxTries; do {
$mysql = new mysqli($host, $user, $password, '', $port);
if ($maxTries <= 0) if ($mysql->connect_error)
{ {
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($db) . '`'))
{
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n");
$mysql->close();
exit(1);
}
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();
}
elseif ($dbType === 'pgsql')
{
$port = $port ? (int)$port : 5432;
$maxTries = 10;
do {
$connection = "host={$host} port={$port} user={$user} password={$password}";
$dbconn = @pg_connect($connection);
if (!$dbconn)
{
fwrite($stderr, "\nPostgreSQL Connection Error\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while (!$dbconn);
$query = "SELECT 1 FROM pg_database WHERE datname = '$db'";
$result = pg_query($dbconn, $query);
if (pg_num_rows($result) == 0)
{
$createDbQuery = "CREATE DATABASE \"$db\"";
if (!pg_query($dbconn, $createDbQuery))
{
fwrite($stderr, "\nPostgreSQL 'CREATE DATABASE' Error\n");
pg_close($dbconn);
exit(1); exit(1);
} }
sleep(3);
} }
}
while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) fwrite($stderr, "\nPostgreSQL Database Created\n");
pg_close($dbconn);
}
else
{ {
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n"); fwrite($stderr, "\nInvalid database type. Please provide 'pgsql' or 'mysqli'.\n");
$mysql->close();
exit(1); exit(1);
} }
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();

View File

@ -120,7 +120,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi fi
# Ensure the MySQL Database is created # Ensure the MySQL Database is created
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" "${JOOMLA_DB_TYPE:-mysqli}"
echo >&2 "========================================================================" echo >&2 "========================================================================"
echo >&2 echo >&2

View File

@ -1,5 +1,5 @@
<?php <?php
// Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME" // Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME", 5 => "$JOOMLA_DB_TYPE"
$stderr = fopen('php://stderr', 'w'); $stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nEnsuring Joomla database is present\n"); fwrite($stderr, "\nEnsuring Joomla database is present\n");
@ -10,40 +10,93 @@ if (strpos($argv[1], ':') !== false)
else else
{ {
$host = $argv[1]; $host = $argv[1];
$port = 3306; $port = null;
} }
$maxTries = 10; $user = $argv[2];
$password = $argv[3];
$db = $argv[4];
$dbType = strtolower($argv[5]);
// set original default behaviour for PHP 8.1 and higher if ($dbType === 'mysqli')
// see https://www.php.net/manual/en/mysqli-driver.report-mode.php
mysqli_report(MYSQLI_REPORT_OFF);
do
{ {
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port); $port = $port ? (int)$port : 3306;
$maxTries = 10;
if ($mysql->connect_error) // set original default behaviour for PHP 8.1 and higher
{ // see https://www.php.net/manual/en/mysqli-driver.report-mode.php
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n"); mysqli_report(MYSQLI_REPORT_OFF);
--$maxTries; do {
$mysql = new mysqli($host, $user, $password, '', $port);
if ($maxTries <= 0) if ($mysql->connect_error)
{ {
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($db) . '`'))
{
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n");
$mysql->close();
exit(1);
}
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();
}
elseif ($dbType === 'pgsql')
{
$port = $port ? (int)$port : 5432;
$maxTries = 10;
do {
$connection = "host={$host} port={$port} user={$user} password={$password}";
$dbconn = @pg_connect($connection);
if (!$dbconn)
{
fwrite($stderr, "\nPostgreSQL Connection Error\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while (!$dbconn);
$query = "SELECT 1 FROM pg_database WHERE datname = '$db'";
$result = pg_query($dbconn, $query);
if (pg_num_rows($result) == 0)
{
$createDbQuery = "CREATE DATABASE \"$db\"";
if (!pg_query($dbconn, $createDbQuery))
{
fwrite($stderr, "\nPostgreSQL 'CREATE DATABASE' Error\n");
pg_close($dbconn);
exit(1); exit(1);
} }
sleep(3);
} }
}
while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) fwrite($stderr, "\nPostgreSQL Database Created\n");
pg_close($dbconn);
}
else
{ {
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n"); fwrite($stderr, "\nInvalid database type. Please provide 'pgsql' or 'mysqli'.\n");
$mysql->close();
exit(1); exit(1);
} }
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();

View File

@ -120,7 +120,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi fi
# Ensure the MySQL Database is created # Ensure the MySQL Database is created
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" "${JOOMLA_DB_TYPE:-mysqli}"
echo >&2 "========================================================================" echo >&2 "========================================================================"
echo >&2 echo >&2

View File

@ -1,5 +1,5 @@
<?php <?php
// Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME" // Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME", 5 => "$JOOMLA_DB_TYPE"
$stderr = fopen('php://stderr', 'w'); $stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nEnsuring Joomla database is present\n"); fwrite($stderr, "\nEnsuring Joomla database is present\n");
@ -10,40 +10,93 @@ if (strpos($argv[1], ':') !== false)
else else
{ {
$host = $argv[1]; $host = $argv[1];
$port = 3306; $port = null;
} }
$maxTries = 10; $user = $argv[2];
$password = $argv[3];
$db = $argv[4];
$dbType = strtolower($argv[5]);
// set original default behaviour for PHP 8.1 and higher if ($dbType === 'mysqli')
// see https://www.php.net/manual/en/mysqli-driver.report-mode.php
mysqli_report(MYSQLI_REPORT_OFF);
do
{ {
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port); $port = $port ? (int)$port : 3306;
$maxTries = 10;
if ($mysql->connect_error) // set original default behaviour for PHP 8.1 and higher
{ // see https://www.php.net/manual/en/mysqli-driver.report-mode.php
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n"); mysqli_report(MYSQLI_REPORT_OFF);
--$maxTries; do {
$mysql = new mysqli($host, $user, $password, '', $port);
if ($maxTries <= 0) if ($mysql->connect_error)
{ {
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($db) . '`'))
{
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n");
$mysql->close();
exit(1);
}
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();
}
elseif ($dbType === 'pgsql')
{
$port = $port ? (int)$port : 5432;
$maxTries = 10;
do {
$connection = "host={$host} port={$port} user={$user} password={$password}";
$dbconn = @pg_connect($connection);
if (!$dbconn)
{
fwrite($stderr, "\nPostgreSQL Connection Error\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while (!$dbconn);
$query = "SELECT 1 FROM pg_database WHERE datname = '$db'";
$result = pg_query($dbconn, $query);
if (pg_num_rows($result) == 0)
{
$createDbQuery = "CREATE DATABASE \"$db\"";
if (!pg_query($dbconn, $createDbQuery))
{
fwrite($stderr, "\nPostgreSQL 'CREATE DATABASE' Error\n");
pg_close($dbconn);
exit(1); exit(1);
} }
sleep(3);
} }
}
while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) fwrite($stderr, "\nPostgreSQL Database Created\n");
pg_close($dbconn);
}
else
{ {
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n"); fwrite($stderr, "\nInvalid database type. Please provide 'pgsql' or 'mysqli'.\n");
$mysql->close();
exit(1); exit(1);
} }
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();

View File

@ -120,7 +120,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi fi
# Ensure the MySQL Database is created # Ensure the MySQL Database is created
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" "${JOOMLA_DB_TYPE:-mysqli}"
echo >&2 "========================================================================" echo >&2 "========================================================================"
echo >&2 echo >&2

View File

@ -1,5 +1,5 @@
<?php <?php
// Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME" // Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME", 5 => "$JOOMLA_DB_TYPE"
$stderr = fopen('php://stderr', 'w'); $stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nEnsuring Joomla database is present\n"); fwrite($stderr, "\nEnsuring Joomla database is present\n");
@ -10,40 +10,93 @@ if (strpos($argv[1], ':') !== false)
else else
{ {
$host = $argv[1]; $host = $argv[1];
$port = 3306; $port = null;
} }
$maxTries = 10; $user = $argv[2];
$password = $argv[3];
$db = $argv[4];
$dbType = strtolower($argv[5]);
// set original default behaviour for PHP 8.1 and higher if ($dbType === 'mysqli')
// see https://www.php.net/manual/en/mysqli-driver.report-mode.php
mysqli_report(MYSQLI_REPORT_OFF);
do
{ {
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port); $port = $port ? (int)$port : 3306;
$maxTries = 10;
if ($mysql->connect_error) // set original default behaviour for PHP 8.1 and higher
{ // see https://www.php.net/manual/en/mysqli-driver.report-mode.php
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n"); mysqli_report(MYSQLI_REPORT_OFF);
--$maxTries; do {
$mysql = new mysqli($host, $user, $password, '', $port);
if ($maxTries <= 0) if ($mysql->connect_error)
{ {
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($db) . '`'))
{
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n");
$mysql->close();
exit(1);
}
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();
}
elseif ($dbType === 'pgsql')
{
$port = $port ? (int)$port : 5432;
$maxTries = 10;
do {
$connection = "host={$host} port={$port} user={$user} password={$password}";
$dbconn = @pg_connect($connection);
if (!$dbconn)
{
fwrite($stderr, "\nPostgreSQL Connection Error\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while (!$dbconn);
$query = "SELECT 1 FROM pg_database WHERE datname = '$db'";
$result = pg_query($dbconn, $query);
if (pg_num_rows($result) == 0)
{
$createDbQuery = "CREATE DATABASE \"$db\"";
if (!pg_query($dbconn, $createDbQuery))
{
fwrite($stderr, "\nPostgreSQL 'CREATE DATABASE' Error\n");
pg_close($dbconn);
exit(1); exit(1);
} }
sleep(3);
} }
}
while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) fwrite($stderr, "\nPostgreSQL Database Created\n");
pg_close($dbconn);
}
else
{ {
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n"); fwrite($stderr, "\nInvalid database type. Please provide 'pgsql' or 'mysqli'.\n");
$mysql->close();
exit(1); exit(1);
} }
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();

View File

@ -120,7 +120,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi fi
# Ensure the MySQL Database is created # Ensure the MySQL Database is created
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" "${JOOMLA_DB_TYPE:-mysqli}"
echo >&2 "========================================================================" echo >&2 "========================================================================"
echo >&2 echo >&2

View File

@ -1,5 +1,5 @@
<?php <?php
// Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME" // Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME", 5 => "$JOOMLA_DB_TYPE"
$stderr = fopen('php://stderr', 'w'); $stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nEnsuring Joomla database is present\n"); fwrite($stderr, "\nEnsuring Joomla database is present\n");
@ -10,40 +10,93 @@ if (strpos($argv[1], ':') !== false)
else else
{ {
$host = $argv[1]; $host = $argv[1];
$port = 3306; $port = null;
} }
$maxTries = 10; $user = $argv[2];
$password = $argv[3];
$db = $argv[4];
$dbType = strtolower($argv[5]);
// set original default behaviour for PHP 8.1 and higher if ($dbType === 'mysqli')
// see https://www.php.net/manual/en/mysqli-driver.report-mode.php
mysqli_report(MYSQLI_REPORT_OFF);
do
{ {
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port); $port = $port ? (int)$port : 3306;
$maxTries = 10;
if ($mysql->connect_error) // set original default behaviour for PHP 8.1 and higher
{ // see https://www.php.net/manual/en/mysqli-driver.report-mode.php
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n"); mysqli_report(MYSQLI_REPORT_OFF);
--$maxTries; do {
$mysql = new mysqli($host, $user, $password, '', $port);
if ($maxTries <= 0) if ($mysql->connect_error)
{ {
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($db) . '`'))
{
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n");
$mysql->close();
exit(1);
}
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();
}
elseif ($dbType === 'pgsql')
{
$port = $port ? (int)$port : 5432;
$maxTries = 10;
do {
$connection = "host={$host} port={$port} user={$user} password={$password}";
$dbconn = @pg_connect($connection);
if (!$dbconn)
{
fwrite($stderr, "\nPostgreSQL Connection Error\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while (!$dbconn);
$query = "SELECT 1 FROM pg_database WHERE datname = '$db'";
$result = pg_query($dbconn, $query);
if (pg_num_rows($result) == 0)
{
$createDbQuery = "CREATE DATABASE \"$db\"";
if (!pg_query($dbconn, $createDbQuery))
{
fwrite($stderr, "\nPostgreSQL 'CREATE DATABASE' Error\n");
pg_close($dbconn);
exit(1); exit(1);
} }
sleep(3);
} }
}
while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) fwrite($stderr, "\nPostgreSQL Database Created\n");
pg_close($dbconn);
}
else
{ {
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n"); fwrite($stderr, "\nInvalid database type. Please provide 'pgsql' or 'mysqli'.\n");
$mysql->close();
exit(1); exit(1);
} }
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();

View File

@ -120,7 +120,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi fi
# Ensure the MySQL Database is created # Ensure the MySQL Database is created
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" "${JOOMLA_DB_TYPE:-mysqli}"
echo >&2 "========================================================================" echo >&2 "========================================================================"
echo >&2 echo >&2

View File

@ -1,5 +1,5 @@
<?php <?php
// Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME" // Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME", 5 => "$JOOMLA_DB_TYPE"
$stderr = fopen('php://stderr', 'w'); $stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nEnsuring Joomla database is present\n"); fwrite($stderr, "\nEnsuring Joomla database is present\n");
@ -10,40 +10,93 @@ if (strpos($argv[1], ':') !== false)
else else
{ {
$host = $argv[1]; $host = $argv[1];
$port = 3306; $port = null;
} }
$maxTries = 10; $user = $argv[2];
$password = $argv[3];
$db = $argv[4];
$dbType = strtolower($argv[5]);
// set original default behaviour for PHP 8.1 and higher if ($dbType === 'mysqli')
// see https://www.php.net/manual/en/mysqli-driver.report-mode.php
mysqli_report(MYSQLI_REPORT_OFF);
do
{ {
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port); $port = $port ? (int)$port : 3306;
$maxTries = 10;
if ($mysql->connect_error) // set original default behaviour for PHP 8.1 and higher
{ // see https://www.php.net/manual/en/mysqli-driver.report-mode.php
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n"); mysqli_report(MYSQLI_REPORT_OFF);
--$maxTries; do {
$mysql = new mysqli($host, $user, $password, '', $port);
if ($maxTries <= 0) if ($mysql->connect_error)
{ {
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($db) . '`'))
{
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n");
$mysql->close();
exit(1);
}
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();
}
elseif ($dbType === 'pgsql')
{
$port = $port ? (int)$port : 5432;
$maxTries = 10;
do {
$connection = "host={$host} port={$port} user={$user} password={$password}";
$dbconn = @pg_connect($connection);
if (!$dbconn)
{
fwrite($stderr, "\nPostgreSQL Connection Error\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while (!$dbconn);
$query = "SELECT 1 FROM pg_database WHERE datname = '$db'";
$result = pg_query($dbconn, $query);
if (pg_num_rows($result) == 0)
{
$createDbQuery = "CREATE DATABASE \"$db\"";
if (!pg_query($dbconn, $createDbQuery))
{
fwrite($stderr, "\nPostgreSQL 'CREATE DATABASE' Error\n");
pg_close($dbconn);
exit(1); exit(1);
} }
sleep(3);
} }
}
while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) fwrite($stderr, "\nPostgreSQL Database Created\n");
pg_close($dbconn);
}
else
{ {
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n"); fwrite($stderr, "\nInvalid database type. Please provide 'pgsql' or 'mysqli'.\n");
$mysql->close();
exit(1); exit(1);
} }
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();

View File

@ -120,7 +120,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi fi
# Ensure the MySQL Database is created # Ensure the MySQL Database is created
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" "${JOOMLA_DB_TYPE:-mysqli}"
echo >&2 "========================================================================" echo >&2 "========================================================================"
echo >&2 echo >&2

View File

@ -1,5 +1,5 @@
<?php <?php
// Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME" // Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME", 5 => "$JOOMLA_DB_TYPE"
$stderr = fopen('php://stderr', 'w'); $stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nEnsuring Joomla database is present\n"); fwrite($stderr, "\nEnsuring Joomla database is present\n");
@ -10,40 +10,93 @@ if (strpos($argv[1], ':') !== false)
else else
{ {
$host = $argv[1]; $host = $argv[1];
$port = 3306; $port = null;
} }
$maxTries = 10; $user = $argv[2];
$password = $argv[3];
$db = $argv[4];
$dbType = strtolower($argv[5]);
// set original default behaviour for PHP 8.1 and higher if ($dbType === 'mysqli')
// see https://www.php.net/manual/en/mysqli-driver.report-mode.php
mysqli_report(MYSQLI_REPORT_OFF);
do
{ {
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port); $port = $port ? (int)$port : 3306;
$maxTries = 10;
if ($mysql->connect_error) // set original default behaviour for PHP 8.1 and higher
{ // see https://www.php.net/manual/en/mysqli-driver.report-mode.php
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n"); mysqli_report(MYSQLI_REPORT_OFF);
--$maxTries; do {
$mysql = new mysqli($host, $user, $password, '', $port);
if ($maxTries <= 0) if ($mysql->connect_error)
{ {
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($db) . '`'))
{
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n");
$mysql->close();
exit(1);
}
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();
}
elseif ($dbType === 'pgsql')
{
$port = $port ? (int)$port : 5432;
$maxTries = 10;
do {
$connection = "host={$host} port={$port} user={$user} password={$password}";
$dbconn = @pg_connect($connection);
if (!$dbconn)
{
fwrite($stderr, "\nPostgreSQL Connection Error\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while (!$dbconn);
$query = "SELECT 1 FROM pg_database WHERE datname = '$db'";
$result = pg_query($dbconn, $query);
if (pg_num_rows($result) == 0)
{
$createDbQuery = "CREATE DATABASE \"$db\"";
if (!pg_query($dbconn, $createDbQuery))
{
fwrite($stderr, "\nPostgreSQL 'CREATE DATABASE' Error\n");
pg_close($dbconn);
exit(1); exit(1);
} }
sleep(3);
} }
}
while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) fwrite($stderr, "\nPostgreSQL Database Created\n");
pg_close($dbconn);
}
else
{ {
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n"); fwrite($stderr, "\nInvalid database type. Please provide 'pgsql' or 'mysqli'.\n");
$mysql->close();
exit(1); exit(1);
} }
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();

View File

@ -120,7 +120,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi fi
# Ensure the MySQL Database is created # Ensure the MySQL Database is created
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" "${JOOMLA_DB_TYPE:-mysqli}"
echo >&2 "========================================================================" echo >&2 "========================================================================"
echo >&2 echo >&2

View File

@ -1,5 +1,5 @@
<?php <?php
// Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME" // Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME", 5 => "$JOOMLA_DB_TYPE"
$stderr = fopen('php://stderr', 'w'); $stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nEnsuring Joomla database is present\n"); fwrite($stderr, "\nEnsuring Joomla database is present\n");
@ -10,40 +10,93 @@ if (strpos($argv[1], ':') !== false)
else else
{ {
$host = $argv[1]; $host = $argv[1];
$port = 3306; $port = null;
} }
$maxTries = 10; $user = $argv[2];
$password = $argv[3];
$db = $argv[4];
$dbType = strtolower($argv[5]);
// set original default behaviour for PHP 8.1 and higher if ($dbType === 'mysqli')
// see https://www.php.net/manual/en/mysqli-driver.report-mode.php
mysqli_report(MYSQLI_REPORT_OFF);
do
{ {
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port); $port = $port ? (int)$port : 3306;
$maxTries = 10;
if ($mysql->connect_error) // set original default behaviour for PHP 8.1 and higher
{ // see https://www.php.net/manual/en/mysqli-driver.report-mode.php
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n"); mysqli_report(MYSQLI_REPORT_OFF);
--$maxTries; do {
$mysql = new mysqli($host, $user, $password, '', $port);
if ($maxTries <= 0) if ($mysql->connect_error)
{ {
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($db) . '`'))
{
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n");
$mysql->close();
exit(1);
}
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();
}
elseif ($dbType === 'pgsql')
{
$port = $port ? (int)$port : 5432;
$maxTries = 10;
do {
$connection = "host={$host} port={$port} user={$user} password={$password}";
$dbconn = @pg_connect($connection);
if (!$dbconn)
{
fwrite($stderr, "\nPostgreSQL Connection Error\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while (!$dbconn);
$query = "SELECT 1 FROM pg_database WHERE datname = '$db'";
$result = pg_query($dbconn, $query);
if (pg_num_rows($result) == 0)
{
$createDbQuery = "CREATE DATABASE \"$db\"";
if (!pg_query($dbconn, $createDbQuery))
{
fwrite($stderr, "\nPostgreSQL 'CREATE DATABASE' Error\n");
pg_close($dbconn);
exit(1); exit(1);
} }
sleep(3);
} }
}
while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) fwrite($stderr, "\nPostgreSQL Database Created\n");
pg_close($dbconn);
}
else
{ {
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n"); fwrite($stderr, "\nInvalid database type. Please provide 'pgsql' or 'mysqli'.\n");
$mysql->close();
exit(1); exit(1);
} }
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();

View File

@ -120,7 +120,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi fi
# Ensure the MySQL Database is created # Ensure the MySQL Database is created
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" "${JOOMLA_DB_TYPE:-mysqli}"
echo >&2 "========================================================================" echo >&2 "========================================================================"
echo >&2 echo >&2

View File

@ -1,5 +1,5 @@
<?php <?php
// Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME" // Args: 0 => makedb.php, 1 => "$JOOMLA_DB_HOST", 2 => "$JOOMLA_DB_USER", 3 => "$JOOMLA_DB_PASSWORD", 4 => "$JOOMLA_DB_NAME", 5 => "$JOOMLA_DB_TYPE"
$stderr = fopen('php://stderr', 'w'); $stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nEnsuring Joomla database is present\n"); fwrite($stderr, "\nEnsuring Joomla database is present\n");
@ -10,40 +10,93 @@ if (strpos($argv[1], ':') !== false)
else else
{ {
$host = $argv[1]; $host = $argv[1];
$port = 3306; $port = null;
} }
$maxTries = 10; $user = $argv[2];
$password = $argv[3];
$db = $argv[4];
$dbType = strtolower($argv[5]);
// set original default behaviour for PHP 8.1 and higher if ($dbType === 'mysqli')
// see https://www.php.net/manual/en/mysqli-driver.report-mode.php
mysqli_report(MYSQLI_REPORT_OFF);
do
{ {
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port); $port = $port ? (int)$port : 3306;
$maxTries = 10;
if ($mysql->connect_error) // set original default behaviour for PHP 8.1 and higher
{ // see https://www.php.net/manual/en/mysqli-driver.report-mode.php
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n"); mysqli_report(MYSQLI_REPORT_OFF);
--$maxTries; do {
$mysql = new mysqli($host, $user, $password, '', $port);
if ($maxTries <= 0) if ($mysql->connect_error)
{ {
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($db) . '`'))
{
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n");
$mysql->close();
exit(1);
}
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();
}
elseif ($dbType === 'pgsql')
{
$port = $port ? (int)$port : 5432;
$maxTries = 10;
do {
$connection = "host={$host} port={$port} user={$user} password={$password}";
$dbconn = @pg_connect($connection);
if (!$dbconn)
{
fwrite($stderr, "\nPostgreSQL Connection Error\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
} while (!$dbconn);
$query = "SELECT 1 FROM pg_database WHERE datname = '$db'";
$result = pg_query($dbconn, $query);
if (pg_num_rows($result) == 0)
{
$createDbQuery = "CREATE DATABASE \"$db\"";
if (!pg_query($dbconn, $createDbQuery))
{
fwrite($stderr, "\nPostgreSQL 'CREATE DATABASE' Error\n");
pg_close($dbconn);
exit(1); exit(1);
} }
sleep(3);
} }
}
while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) fwrite($stderr, "\nPostgreSQL Database Created\n");
pg_close($dbconn);
}
else
{ {
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n"); fwrite($stderr, "\nInvalid database type. Please provide 'pgsql' or 'mysqli'.\n");
$mysql->close();
exit(1); exit(1);
} }
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();