2019-01-31 04:16:25 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of Flarum.
|
|
|
|
*
|
2019-11-28 08:16:50 +08:00
|
|
|
* For detailed copyright and license information, please view the
|
|
|
|
* LICENSE file that was distributed with this source code.
|
2019-01-31 04:16:25 +08:00
|
|
|
*/
|
|
|
|
|
2020-06-20 04:16:03 +08:00
|
|
|
use Flarum\Foundation\Paths;
|
2019-01-31 04:16:25 +08:00
|
|
|
use Flarum\Install\AdminUser;
|
2019-09-24 06:26:51 +08:00
|
|
|
use Flarum\Install\BaseUrl;
|
2019-01-31 04:16:25 +08:00
|
|
|
use Flarum\Install\DatabaseConfig;
|
|
|
|
use Flarum\Install\Installation;
|
|
|
|
|
|
|
|
require __DIR__.'/../../vendor/autoload.php';
|
|
|
|
|
2020-05-09 04:15:55 +08:00
|
|
|
$host = getenv('DB_HOST') ?: 'localhost';
|
|
|
|
$port = intval(getenv('DB_PORT') ?: 3306);
|
|
|
|
$name = getenv('DB_DATABASE') ?: 'flarum_test';
|
|
|
|
$user = getenv('DB_USERNAME') ?: 'root';
|
|
|
|
$pass = getenv('DB_PASSWORD') ?: '';
|
|
|
|
$pref = getenv('DB_PREFIX') ?: '';
|
2019-02-01 04:30:16 +08:00
|
|
|
|
|
|
|
echo "Connecting to database $name at $host:$port.\n";
|
|
|
|
echo "Logging in as $user with password '$pass'.\n";
|
|
|
|
echo "Table prefix: '$pref'\n";
|
|
|
|
|
|
|
|
echo "\n\nCancel now if that's not what you want...\n";
|
|
|
|
echo "Use the following environment variables for configuration:\n";
|
|
|
|
echo "DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD, DB_PREFIX\n";
|
|
|
|
|
|
|
|
sleep(5);
|
|
|
|
|
|
|
|
echo "\nOff we go...\n";
|
|
|
|
|
2019-01-31 04:16:25 +08:00
|
|
|
/*
|
|
|
|
* Setup installation configuration
|
|
|
|
*/
|
|
|
|
|
|
|
|
$installation = new Installation(
|
2020-06-20 04:16:03 +08:00
|
|
|
new Paths([
|
|
|
|
'base' => __DIR__.'/tmp',
|
|
|
|
'public' => __DIR__.'/tmp/public',
|
|
|
|
'storage' => __DIR__.'/tmp/storage',
|
|
|
|
'vendor' => __DIR__.'/../../vendor',
|
|
|
|
])
|
2019-01-31 04:16:25 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
$pipeline = $installation
|
|
|
|
->configPath('config.php')
|
|
|
|
->debugMode(true)
|
2019-09-24 06:26:51 +08:00
|
|
|
->baseUrl(BaseUrl::fromString('http://localhost'))
|
2020-05-09 04:15:55 +08:00
|
|
|
->databaseConfig(
|
|
|
|
new DatabaseConfig('mysql', $host, $port, $name, $user, $pass, $pref)
|
|
|
|
)
|
2019-01-31 04:16:25 +08:00
|
|
|
->adminUser(new AdminUser(
|
|
|
|
'admin',
|
2020-05-20 06:18:00 +08:00
|
|
|
'password',
|
|
|
|
'admin@machine.local'
|
2019-01-31 04:16:25 +08:00
|
|
|
))
|
|
|
|
->settings(['mail_driver' => 'log'])
|
|
|
|
->build();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Run the actual configuration
|
|
|
|
*/
|
|
|
|
|
|
|
|
$pipeline->run();
|
2019-02-01 04:30:16 +08:00
|
|
|
|
|
|
|
echo "Installation complete\n";
|