2018-04-28 12:20:07 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
2022-06-19 21:29:59 +00:00
|
|
|
((PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 3) || PHP_MAJOR_VERSION > 7) ?: die('Sorry, PHP 7.3 or above is required to run XBackBone.');
|
2021-07-31 11:09:45 +00:00
|
|
|
if (PHP_SAPI !== 'cli') {
|
2019-11-13 12:53:45 +00:00
|
|
|
die();
|
2018-04-28 12:20:07 +00:00
|
|
|
}
|
|
|
|
|
2019-11-13 12:53:45 +00:00
|
|
|
use App\Database\Migrator;
|
2020-04-13 15:46:10 +00:00
|
|
|
use DI\ContainerBuilder;
|
2019-09-03 19:53:12 +00:00
|
|
|
|
2019-11-13 12:53:45 +00:00
|
|
|
require __DIR__.'/../vendor/autoload.php';
|
2019-09-03 19:53:12 +00:00
|
|
|
|
2020-04-13 15:46:10 +00:00
|
|
|
define('BASE_DIR', realpath(__DIR__.'/../').DIRECTORY_SEPARATOR);
|
|
|
|
|
2019-11-13 12:53:45 +00:00
|
|
|
$config = include __DIR__.'/../config.php';
|
2018-04-28 12:20:07 +00:00
|
|
|
|
|
|
|
if (!$config) {
|
2019-11-13 12:53:45 +00:00
|
|
|
die('config.php not found. Please create a new one.');
|
2018-04-28 12:20:07 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 15:46:10 +00:00
|
|
|
chdir(BASE_DIR);
|
|
|
|
|
|
|
|
$builder = new ContainerBuilder();
|
|
|
|
$builder->addDefinitions(BASE_DIR.'bootstrap/container.php');
|
|
|
|
|
|
|
|
$container = $builder->build();
|
|
|
|
$container->set('config', $config);
|
2018-04-28 12:20:07 +00:00
|
|
|
|
2020-04-13 15:46:10 +00:00
|
|
|
$db = $container->get('database');
|
2018-04-28 12:20:07 +00:00
|
|
|
|
2020-04-05 12:53:22 +00:00
|
|
|
$migrator = new Migrator($db, 'resources/schemas');
|
2019-11-13 12:53:45 +00:00
|
|
|
$migrator->migrate();
|
2020-04-13 15:46:10 +00:00
|
|
|
$migrator->reSyncQuotas($container->get('storage'));
|
2018-04-28 12:20:07 +00:00
|
|
|
|
|
|
|
if (isset($argv[1]) && $argv[1] === '--install') {
|
2019-11-13 12:53:45 +00:00
|
|
|
$db->query("INSERT INTO `users` (`email`, `username`, `password`, `is_admin`, `user_code`) VALUES ('admin@example.com', 'admin', ?, 1, ?)", [password_hash('admin', PASSWORD_DEFAULT), humanRandomString(5)]);
|
2018-04-28 12:20:07 +00:00
|
|
|
}
|
|
|
|
|
2020-03-13 18:44:42 +00:00
|
|
|
if (file_exists(__DIR__.'/../install') && (!isset($config['debug']) || !$config['debug'])) {
|
2020-04-06 10:55:58 +00:00
|
|
|
removeDirectory(__DIR__.'/../install');
|
2019-11-17 18:48:37 +00:00
|
|
|
}
|
2019-09-03 19:53:12 +00:00
|
|
|
|
2020-04-26 15:58:31 +00:00
|
|
|
echo 'If you are upgrading from a previous version, please run a "php bin' . DIRECTORY_SEPARATOR . 'clean".'.PHP_EOL;
|
2019-11-13 12:53:45 +00:00
|
|
|
echo 'Done.'.PHP_EOL;
|
2020-04-26 13:00:16 +00:00
|
|
|
exit(0);
|