Installer updates

Added probe.php
Added new installer views and controllers
Updated AuthController
Updated Middlewares
Updated Commands for installation process
This commit is contained in:
Manish Verma
2018-08-07 13:45:46 +05:30
parent 1ac0f42a58
commit 22d3bb4036
28 changed files with 1197 additions and 405 deletions

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Console\Commands;
use DB;
use Illuminate\Console\Command;
class DropTables extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'droptables';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Drops all tables';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$colname = 'Tables_in_'.env('DB_DATABASE');
$droplist = \Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
$droplist = implode(',', $droplist);
DB::beginTransaction();
//turn off referential integrity
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
DB::statement("DROP TABLE $droplist");
//turn referential integrity back on
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
DB::commit();
$this->comment(PHP_EOL.'If no errors showed up, all tables were dropped'.PHP_EOL);
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace App\Console\Commands;
use App\Http\Controllers\Installer\helpdesk\InstallController;
use Illuminate\Console\Command;
class Install extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'install:faveo';
/**
* The console command description.
*
* @var string
*/
protected $description = 'to install faveo';
protected $install;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
$this->install = new InstallController();
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
try {
$this->appEnv();
if ($this->confirm('Do you want to intall faveo?')) {
$default = $this->choice(
'Which sql engine would you like to use?', ['mysql']
);
$host = $this->ask('Enter your sql host');
$database = $this->ask('Enter your database name');
$dbusername = $this->ask('Enter your database username');
$dbpassword = $this->ask('Enter your database password (blank if not entered)', false);
$port = $this->ask('Enter your sql port (blank if not entered)', false);
$this->install->env($default, $host, $port, $database, $dbusername, $dbpassword);
$this->info('.env file has created');
$this->call('preinsatall:check');
$this->alert("please run 'php artisan install:db'");
} else {
$this->info('We hope, you will try next time');
}
} catch (\Exception $ex) {
$this->error($ex->getMessage());
}
}
public function appEnv()
{
$extensions = [
'curl',
'ctype',
'imap',
'mbstring',
'mcrypt',
'mysql',
'openssl',
'tokenizer',
'zip',
'pdo',
'mysqli',
'bcmath',
'iconv',
//'ioncube_loader_dar_5.6',
];
$result = [];
foreach ($extensions as $key => $extension) {
$result[$key]['extension'] = $extension;
if (!extension_loaded($extension)) {
$result[$key]['status'] = "Not Loading, Please open '".php_ini_loaded_file()."' and add 'extension = ".$extension;
} else {
$result[$key]['status'] = 'Loading';
}
}
$result['php']['extension'] = 'PHP';
if (phpversion() === 7.0) {
$result['php']['status'] = 'PHP version supports';
} else {
$result['php']['status'] = "PHP version doesn't supports please upgrade to 7.0";
}
$headers = ['Extension', 'Status'];
$this->table($headers, $result);
}
}

View File

@@ -0,0 +1,89 @@
<?php
namespace App\Console\Commands;
use App\Http\Controllers\Installer\helpdesk\InstallController;
use DB;
use Illuminate\Console\Command;
class InstallDB extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'install:db';
/**
* The console command description.
*
* @var string
*/
protected $description = 'installing database';
protected $install;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
$this->install = new InstallController();
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
try {
if ($this->confirm('Do you want to migrate tables now?')) {
$env = base_path().DIRECTORY_SEPARATOR.'.env';
if (!is_file($env)) {
throw new \Exception("Please run 'php artisan install:faveo'");
}
$dummy_confirm = $this->confirm('Would you like to install dummy data in database to test before going live?');
$this->call('key:generate', ['--force' => true]);
if (!$dummy_confirm) {
$this->call('install:migrate');
$this->call('install:seed');
} else {
$path = base_path().'/DB/dummy-data.sql';
DB::unprepared(file_get_contents($path));
}
$headers = ['user_name', 'email', 'password'];
$data = [
[
'user_name' => 'demo_admin',
'email' => '',
'password' => 'demopass',
],
];
$this->table($headers, $data);
$this->warn('Please update your email and change the password immediately');
$this->install->updateInstalEnv();
$this->updateAppUrl();
}
} catch (\Exception $ex) {
$this->error($ex->getMessage());
}
}
public function updateAppUrl()
{
$url = $this->ask('Enter your app url (with http/https and www/non www)');
if (str_finish($url, '/')) {
$url = rtrim($url, '/ ');
}
$systems = new \App\Model\helpdesk\Settings\System();
$system = $systems->first();
$system->url = $url;
$system->save();
$this->info('Thank you! Faveo has been installed successfully');
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class UpdateEncryption extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'encryption';
/**
* The console command description.
*
* @var string
*/
protected $description = 'This update the encryption value from old to AES-256-CBC';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$emails = \App\Model\helpdesk\Email\Emails::get();
foreach ($emails as $email) {
$email->password = encrypt('password');
$email->save();
}
}
}

View File

@@ -18,6 +18,10 @@ class Kernel extends ConsoleKernel
'App\Console\Commands\SendReport',
'App\Console\Commands\CloseWork',
'App\Console\Commands\TicketFetch',
'App\Console\Commands\UpdateEncryption',
\App\Console\Commands\DropTables::class,
\App\Console\Commands\Install::class,
\App\Console\Commands\InstallDB::class,
];
/**
@@ -33,9 +37,11 @@ class Kernel extends ConsoleKernel
if ($this->getCurrentQueue() != 'sync') {
$schedule->command('queue:listen '.$this->getCurrentQueue().' --sleep 60')->everyMinute();
}
$this->execute($schedule, 'fetching');
$this->execute($schedule, 'notification');
$this->execute($schedule, 'work');
$schedule->command('sla-escalate')->everyThirtyMinutes();
}
}
@@ -114,4 +120,14 @@ class Kernel extends ConsoleKernel
return $queue;
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
}