Completed maintenance impl.
Small fixes
This commit is contained in:
parent
7b81478667
commit
3ba38eff2c
5 changed files with 32 additions and 15 deletions
|
@ -16,10 +16,8 @@ class DashboardController extends Controller
|
||||||
*/
|
*/
|
||||||
public function redirects(Request $request, Response $response): Response
|
public function redirects(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
|
if ($request->getParam('afterInstall') !== null && !is_dir(BASE_DIR . 'install')) {
|
||||||
if ($request->getParam('afterInstall') !== null && is_dir('install')) {
|
|
||||||
$this->session->alert(lang('installed'), 'success');
|
$this->session->alert(lang('installed'), 'success');
|
||||||
removeDirectory('install');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect($response, 'home');
|
return redirect($response, 'home');
|
||||||
|
|
|
@ -47,6 +47,10 @@ class UpgradeController extends Controller
|
||||||
return redirect($response, 'system');
|
return redirect($response, 'system');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$config = $this->config;
|
||||||
|
$config['maintenance'] = true;
|
||||||
|
file_put_contents(BASE_DIR . 'config.php', '<?php' . PHP_EOL . 'return ' . var_export($config, true) . ';');
|
||||||
|
|
||||||
$currentFiles = array_merge(
|
$currentFiles = array_merge(
|
||||||
glob_recursive(BASE_DIR . 'app/*'),
|
glob_recursive(BASE_DIR . 'app/*'),
|
||||||
glob_recursive(BASE_DIR . 'bin/*'),
|
glob_recursive(BASE_DIR . 'bin/*'),
|
||||||
|
@ -107,12 +111,11 @@ class UpgradeController extends Controller
|
||||||
$jsonResponse['message'] = lang('already_latest_version');
|
$jsonResponse['message'] = lang('already_latest_version');
|
||||||
$jsonResponse['upgrade'] = false;
|
$jsonResponse['upgrade'] = false;
|
||||||
}
|
}
|
||||||
return $response->withJson($jsonResponse, 200);
|
|
||||||
} catch (\RuntimeException $e) {
|
} catch (\RuntimeException $e) {
|
||||||
$jsonResponse['status'] = 'ERROR';
|
$jsonResponse['status'] = 'ERROR';
|
||||||
$jsonResponse['message'] = $e->getMessage();
|
$jsonResponse['message'] = $e->getMessage();
|
||||||
return $response->withJson($jsonResponse, 503);
|
|
||||||
}
|
}
|
||||||
|
return $response->withJson($jsonResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getApiJson()
|
protected function getApiJson()
|
||||||
|
@ -127,7 +130,7 @@ class UpgradeController extends Controller
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$data = file_get_contents(self::GITHUB_SOURCE_API, false, stream_context_create($opts));
|
$data = @file_get_contents(self::GITHUB_SOURCE_API, false, stream_context_create($opts));
|
||||||
|
|
||||||
if ($data === false) {
|
if ($data === false) {
|
||||||
throw new \RuntimeException('Cannot contact the Github API. Try again.');
|
throw new \RuntimeException('Cannot contact the Github API. Try again.');
|
||||||
|
|
|
@ -13,7 +13,7 @@ if (!file_exists('config.php') && is_dir('install/')) {
|
||||||
header('Location: ./install/');
|
header('Location: ./install/');
|
||||||
exit();
|
exit();
|
||||||
} else if (!file_exists('config.php') && !is_dir('install/')) {
|
} else if (!file_exists('config.php') && !is_dir('install/')) {
|
||||||
die('Cannot find the config file.');
|
exit('Cannot find the config file.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the config
|
// Load the config
|
||||||
|
@ -37,6 +37,10 @@ if (!$config['displayErrorDetails']) {
|
||||||
|
|
||||||
$container = new Container(['settings' => $config]);
|
$container = new Container(['settings' => $config]);
|
||||||
|
|
||||||
|
$container['config'] = function ($container) use ($config) {
|
||||||
|
return $config;
|
||||||
|
};
|
||||||
|
|
||||||
$container['logger'] = function ($container) {
|
$container['logger'] = function ($container) {
|
||||||
$logger = new Logger('app');
|
$logger = new Logger('app');
|
||||||
|
|
||||||
|
@ -133,4 +137,4 @@ $app->add(function (\Slim\Http\Request $request, \Slim\Http\Response $response,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load the application routes
|
// Load the application routes
|
||||||
require 'app/routes.php';
|
require BASE_DIR . 'app/routes.php';
|
|
@ -163,6 +163,8 @@ $app->post('/', function (Request $request, Response $response) use (&$config) {
|
||||||
$this->session->alert('The config folder is not writable (' . __DIR__ . '/../config.php' . ')', 'danger');
|
$this->session->alert('The config folder is not writable (' . __DIR__ . '/../config.php' . ')', 'danger');
|
||||||
return redirect($response, './');
|
return redirect($response, './');
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$config = require __DIR__ . '/../config.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
$dsn = $config['db']['connection'] === 'sqlite' ? __DIR__ . '/../' . $config['db']['dsn'] : $config['db']['dsn'];
|
$dsn = $config['db']['connection'] === 'sqlite' ? __DIR__ . '/../' . $config['db']['dsn'] : $config['db']['dsn'];
|
||||||
|
@ -183,6 +185,18 @@ $app->post('/', function (Request $request, Response $response) use (&$config) {
|
||||||
cleanDirectory(__DIR__ . '/../resources/cache');
|
cleanDirectory(__DIR__ . '/../resources/cache');
|
||||||
cleanDirectory(__DIR__ . '/../resources/sessions');
|
cleanDirectory(__DIR__ . '/../resources/sessions');
|
||||||
|
|
||||||
|
removeDirectory(__DIR__ . '/../install');
|
||||||
|
|
||||||
|
if ($installed) {
|
||||||
|
$config['maintenance'] = false;
|
||||||
|
|
||||||
|
$ret = file_put_contents(__DIR__ . '/../config.php', '<?php' . PHP_EOL . 'return ' . var_export($config, true) . ';');
|
||||||
|
if ($ret === false) {
|
||||||
|
$this->session->alert('The config folder is not writable (' . __DIR__ . '/../config.php' . ')', 'danger');
|
||||||
|
return redirect($response, './');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $response->withRedirect('../?afterInstall=true');
|
return $response->withRedirect('../?afterInstall=true');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -95,14 +95,12 @@ var app = {
|
||||||
$('#checkForUpdatesMessage').empty().text('...');
|
$('#checkForUpdatesMessage').empty().text('...');
|
||||||
$('#doUpgradeButton').prop('disabled', true);
|
$('#doUpgradeButton').prop('disabled', true);
|
||||||
$.get(window.AppConfig.base_url + '/system/checkForUpdates', function (data) {
|
$.get(window.AppConfig.base_url + '/system/checkForUpdates', function (data) {
|
||||||
if (data.status === 'OK') {
|
|
||||||
$('#checkForUpdatesMessage').empty().text(data.message);
|
$('#checkForUpdatesMessage').empty().text(data.message);
|
||||||
if (data.upgrade) {
|
if (data.upgrade) {
|
||||||
$('#doUpgradeButton').prop('disabled', false);
|
$('#doUpgradeButton').prop('disabled', false);
|
||||||
} else {
|
} else {
|
||||||
$('#doUpgradeButton').prop('disabled', true);
|
$('#doUpgradeButton').prop('disabled', true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue