diff --git a/scripts/install b/scripts/install index fbd3f76..bedc712 100644 --- a/scripts/install +++ b/scripts/install @@ -129,10 +129,14 @@ adminemail=$(ynh_user_get_info $admin mail) sed -i "s%YNH_ADMIN_EMAIL%$adminemail%g" ../sources/configuration.yml sed -i "s@YNH_FORUM_TITLE@$title@g" ../sources/configuration.yml sudo cp ../sources/configuration.yml $final_path -#sudo su - www-data -s /bin/bash -c "cd $final_path && php -d memory_limit=-1 flarum install -f configuration.yml" +# Workaround, waiting for beta6 +sudo \cp ../sources/Server.php $final_path/vendor/flarum/core/src/Console/Server.php +sudo su - www-data -s /bin/bash -c "cd $final_path && php -d memory_limit=-1 flarum install -f configuration.yml" sudo rm $final_path/configuration.yml -fi -# Tell user the MySQL credentials for post-installation -echo "MySQL database user is " $dbuser -echo "MySQL database password is " $dbpass +# Generate and add root token for user creation and deletion +roottoken=$(ynh_string_random 40) +rootsql="INSERT INTO api_keys VALUES ('"$roottoken"')" +ynh_mysql_execute_as_root "$rootsql" $dbname +ynh_app_setting_set "$app" root_token "$roottoken" +fi diff --git a/sources/Server.php b/sources/Server.php new file mode 100644 index 0000000..a06201f --- /dev/null +++ b/sources/Server.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Console; + +use Flarum\Console\Command\GenerateExtensionCommand; +use Flarum\Console\Command\GenerateMigrationCommand; +use Flarum\Debug\Console\CacheClearCommand; +use Flarum\Debug\Console\InfoCommand; +use Flarum\Foundation\AbstractServer; +use Flarum\Install\Console\InstallCommand; +use Flarum\Update\Console\MigrateCommand; +use Symfony\Component\Console\Application; + +class Server extends AbstractServer +{ + public function listen() + { + $console = $this->getConsoleApplication(); + + exit($console->run()); + } + + /** + * @return Application + */ + protected function getConsoleApplication() + { + $app = $this->getApp(); + $console = new Application('Flarum', $app->version()); + + $app->register('Flarum\Install\InstallServiceProvider'); + + $commands = [ + InstallCommand::class, + MigrateCommand::class, + GenerateExtensionCommand::class, + GenerateMigrationCommand::class, + ]; + + if ($app->isInstalled()) { + $commands = array_merge($commands, [ + InfoCommand::class, + CacheClearCommand::class + ]); + } + + foreach ($commands as $command) { + $console->add($app->make( + $command, + ['config' => $app->isInstalled() ? $app->make('flarum.config') : []] + )); + } + + return $console; + } +} +