mirror of
https://github.com/shlinkio/shlink.git
synced 2026-09-03 19:52:51 -05:00
Created script to update an already existing system
This commit is contained in:
@@ -1,4 +1,11 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
use Interop\Container\ContainerInterface;
|
||||||
|
use Symfony\Component\Console\Application as CliApp;
|
||||||
|
|
||||||
include 'cli.php';
|
/** @var ContainerInterface $container */
|
||||||
|
$container = include __DIR__ . '/../config/container.php';
|
||||||
|
|
||||||
|
/** @var CliApp $app */
|
||||||
|
$app = $container->get(CliApp::class);
|
||||||
|
$app->run();
|
||||||
|
|||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
use Interop\Container\ContainerInterface;
|
|
||||||
use Symfony\Component\Console\Application as CliApp;
|
|
||||||
|
|
||||||
/** @var ContainerInterface $container */
|
|
||||||
$container = include __DIR__ . '/../config/container.php';
|
|
||||||
|
|
||||||
/** @var CliApp $app */
|
|
||||||
$app = $container->get(CliApp::class);
|
|
||||||
$app->run();
|
|
||||||
+11
-1
@@ -1,4 +1,14 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
use Shlinkio\Shlink\CLI\Command\Install\InstallCommand;
|
||||||
|
use Symfony\Component\Console\Application;
|
||||||
|
use Zend\Config\Writer\PhpArray;
|
||||||
|
|
||||||
include 'install.php';
|
chdir(dirname(__DIR__));
|
||||||
|
|
||||||
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
$app = new Application();
|
||||||
|
$app->add(new InstallCommand(new PhpArray()));
|
||||||
|
$app->setDefaultCommand('shlink:install');
|
||||||
|
$app->run();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
use Shlinkio\Shlink\CLI\Command\Install\InstallCommand;
|
use Shlinkio\Shlink\CLI\Command\Install\UpdateCommand;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Zend\Config\Writer\PhpArray;
|
use Zend\Config\Writer\PhpArray;
|
||||||
|
|
||||||
@@ -9,6 +9,6 @@ chdir(dirname(__DIR__));
|
|||||||
require __DIR__ . '/../vendor/autoload.php';
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
$app = new Application();
|
$app = new Application();
|
||||||
$app->add(new InstallCommand(new PhpArray()));
|
$app->add(new UpdateCommand(new PhpArray()));
|
||||||
$app->setDefaultCommand('shlink:install');
|
$app->setDefaultCommand('shlink:install');
|
||||||
$app->run();
|
$app->run();
|
||||||
@@ -44,6 +44,11 @@ class InstallCommand extends Command
|
|||||||
*/
|
*/
|
||||||
private $configWriter;
|
private $configWriter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InstallCommand constructor.
|
||||||
|
* @param WriterInterface $configWriter
|
||||||
|
* @param callable|null $databaseCreationLogic
|
||||||
|
*/
|
||||||
public function __construct(WriterInterface $configWriter)
|
public function __construct(WriterInterface $configWriter)
|
||||||
{
|
{
|
||||||
parent::__construct(null);
|
parent::__construct(null);
|
||||||
@@ -94,8 +99,7 @@ class InstallCommand extends Command
|
|||||||
$output->writeln(['<info>Custom configuration properly generated!</info>', '']);
|
$output->writeln(['<info>Custom configuration properly generated!</info>', '']);
|
||||||
|
|
||||||
// Generate database
|
// Generate database
|
||||||
$output->writeln('Initializing database...');
|
if (! $this->createDatabase()) {
|
||||||
if (! $this->runCommand('php vendor/bin/doctrine.php orm:schema-tool:create', 'Error generating database.')) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,6 +277,12 @@ class InstallCommand extends Command
|
|||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function createDatabase()
|
||||||
|
{
|
||||||
|
$this->output->writeln('Initializing database...');
|
||||||
|
return $this->runCommand('php vendor/bin/doctrine.php orm:schema-tool:create', 'Error generating database.');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $command
|
* @param string $command
|
||||||
* @param string $errorMessage
|
* @param string $errorMessage
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
namespace Shlinkio\Shlink\CLI\Command\Install;
|
||||||
|
|
||||||
|
use Zend\Config\Writer\WriterInterface;
|
||||||
|
|
||||||
|
class UpdateCommand extends InstallCommand
|
||||||
|
{
|
||||||
|
public function createDatabase()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user