mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-06 12:45:30 +00:00
79 lines
2.2 KiB
PHP
79 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* InstallController.php
|
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
|
*
|
|
* This file is part of Firefly III.
|
|
*
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace FireflyIII\Http\Controllers\System;
|
|
|
|
|
|
use Artisan;
|
|
use FireflyIII\Http\Controllers\Controller;
|
|
use Laravel\Passport\Passport;
|
|
use Log;
|
|
use phpseclib\Crypt\RSA;
|
|
use Symfony\Component\Console\Output\BufferedOutput;
|
|
|
|
/**
|
|
* Class InstallController
|
|
*/
|
|
class InstallController extends Controller
|
|
{
|
|
/**
|
|
* InstallController constructor.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
// empty on purpose.
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
|
*/
|
|
public function migrate()
|
|
{
|
|
Log::debug('Am now calling migrate routine...');
|
|
$output = new BufferedOutput();
|
|
Artisan::call('migrate', ['--seed' => true, '--force' => true]);
|
|
$result = $output->fetch();
|
|
Log::debug($result);
|
|
Log::debug(Artisan::output());
|
|
|
|
// create keys manually because for some reason the passport namespace
|
|
// does not exist
|
|
$rsa = new RSA();
|
|
$keys = $rsa->createKey(4096);
|
|
|
|
list($publicKey, $privateKey) = [
|
|
Passport::keyPath('oauth-public.key'),
|
|
Passport::keyPath('oauth-private.key'),
|
|
];
|
|
|
|
if ((file_exists($publicKey) || file_exists($privateKey))) {
|
|
return redirect(route('index'));
|
|
}
|
|
|
|
file_put_contents($publicKey, array_get($keys, 'publickey'));
|
|
file_put_contents($privateKey, array_get($keys, 'privatekey'));
|
|
|
|
return redirect(route('index'));
|
|
}
|
|
|
|
} |