Cleanup config files if the db setup fails
This commit is contained in:
@@ -158,7 +158,9 @@ class InstallerController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function envsetup(Request $request)
|
public function envsetup(Request $request)
|
||||||
{
|
{
|
||||||
Log::info('ENV setup', $request->post());
|
$log_str = $request->post();
|
||||||
|
$log_str['password'] = '';
|
||||||
|
Log::info('ENV setup', $log_str);
|
||||||
|
|
||||||
// Before writing out the env file, test the DB credentials
|
// Before writing out the env file, test the DB credentials
|
||||||
try {
|
try {
|
||||||
@@ -211,6 +213,7 @@ class InstallerController extends Controller
|
|||||||
$console_out .= $this->dbService->setupDB();
|
$console_out .= $this->dbService->setupDB();
|
||||||
$console_out .= $this->migrationSvc->runAllMigrations();
|
$console_out .= $this->migrationSvc->runAllMigrations();
|
||||||
} catch(QueryException $e) {
|
} catch(QueryException $e) {
|
||||||
|
$this->envService->removeConfigFiles();
|
||||||
flash()->error($e->getMessage());
|
flash()->error($e->getMessage());
|
||||||
return redirect(route('installer.step2'))->withInput();
|
return redirect(route('installer.step2'))->withInput();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,6 +158,31 @@ class ConfigService
|
|||||||
return $opts;
|
return $opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the config files
|
||||||
|
*/
|
||||||
|
public function removeConfigFiles()
|
||||||
|
{
|
||||||
|
$env_file = \App::environmentFilePath();
|
||||||
|
$config_file = \App::environmentPath().'/config.php';
|
||||||
|
|
||||||
|
if (file_exists($env_file)) {
|
||||||
|
try {
|
||||||
|
unlink($env_file);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(file_exists($config_file)) {
|
||||||
|
try {
|
||||||
|
unlink($config_file);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the template file name and write it out
|
* Get the template file name and write it out
|
||||||
* @param $opts
|
* @param $opts
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ class DatabaseService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the database by running the migration commands
|
* Setup the database by running the migration commands
|
||||||
|
* Only run the setup for sqlite, otherwise, we're assuming
|
||||||
|
* that the MySQL database has already been created
|
||||||
*/
|
*/
|
||||||
public function setupDB()
|
public function setupDB()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user