2020-07-09 03:52:53 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
|
|
|
|
class Install extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'application:install {-u|--unattended: Install non-interactively (currently unused: WIP)}';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Installs the application and prepares for production use.';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$basePath = base_path();
|
2021-10-13 00:47:16 +00:00
|
|
|
if (Storage::disk('local')->missing('INSTALLED'))
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
$this->info('[!! Welcome to Rasberry Teams !!]');
|
|
|
|
$this->info('>> Installing...');
|
|
|
|
$this->call('down', [
|
|
|
|
'--message' => 'Down for maintenance. We\'ll be right back!'
|
|
|
|
]);
|
|
|
|
|
|
|
|
copy($basePath . '/.env.example', $basePath . '/.env');
|
|
|
|
$this->call('key:generate');
|
|
|
|
|
|
|
|
$this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.');
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
$npmOut = 0;
|
|
|
|
$npmMessages = [];
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
$npmBuildOut = 0;
|
|
|
|
$npmBuildMessages = [];
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
exec('cd ' . $basePath . ' && npm install --silent', $npmBuildOut, $npmOut);
|
|
|
|
exec('cd ' . $basePath . '&& npm run dev --silent', $npmBuildMessages, $npmBuildOut);
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2020-07-09 04:01:50 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
if($npmOut !== 0 && $npmBuildOut !== 0)
|
|
|
|
{
|
|
|
|
$this->error('[!] One or more errors have ocurred whilst attempting to install dependencies.');
|
|
|
|
$this->error('[!] It is recommended to run this command again, and report a bug if it keeps happening.');
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-07-09 06:03:40 +00:00
|
|
|
|
2020-07-09 04:01:50 +00:00
|
|
|
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
$settings = [];
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
$this->info('>> Configuring application - We\'re going to ask a few questions here!');
|
|
|
|
do
|
|
|
|
{
|
|
|
|
$this->info('== Database Settings (1/6) ==');
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
$settings['DB_USERNAME'] = $this->ask('Database username');
|
|
|
|
$settings['DB_PASSWORD'] = $this->secret('Database password (Input won\'t be seen)');
|
|
|
|
$settings['DB_DATABASE'] = $this->ask('Database name');
|
|
|
|
$settings['DB_PORT'] = $this->ask('Database port');
|
|
|
|
$settings['DB_HOST'] = $this->ask('Database hostname');
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
$this->info('== Antispam Settings (2/6) (Recaptcha v2) ==');
|
|
|
|
$settings['RECAPTCHA_SITE_KEY'] = $this->ask('Site key');
|
|
|
|
$settings['RECAPTCHA_PRIVATE_KEY'] = $this->ask('Private site key');
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
$this->info('== IP Geolocation Settings (3/6) (refer to README.md) ==');
|
|
|
|
$settings['IPGEO_API_KEY'] = $this->ask('API Key');
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
$this->info('== Notification Settings (4/6) (Email) ==');
|
|
|
|
$settings['MAIL_USERNAME'] = $this->ask('SMTP Username');
|
|
|
|
$settings['MAIL_PASSWORD'] = $this->secret('SMTP Password (Input won\'t be seen)');
|
|
|
|
$settings['MAIL_PORT'] = $this->ask('SMTP Server Port');
|
|
|
|
$settings['MAIL_HOST'] = $this->ask('SMTP Server Hostname');
|
|
|
|
$settings['MAIL_FROM_ADDRESS'] = $this->ask('E-mail address to send from');
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
$this->info('== Notification Settings (5/6) (Slack) ==');
|
|
|
|
$settings['SLACK_INTEGRATION_WEBHOOK'] = $this->ask('Integration webhook URL');
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
$this->info('== Web Settings (6/6) ==');
|
|
|
|
$settings['APP_URL'] = $this->ask('Application\'s URL (ex. https://where.you.installed.theapp.com): ');
|
|
|
|
$settings['APP_LOGO'] = $this->ask('App logo (Link to an image): ');
|
|
|
|
$settings['APP_SITEHOMEPAGE'] = $this->ask('Site homepage (appears in the main header): ');
|
2020-09-07 22:22:25 +00:00
|
|
|
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
} while(!$this->confirm('Are you sure you want to save these settings? You can always go back and try again.'));
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
foreach($settings as $keyname => $value)
|
|
|
|
{
|
|
|
|
$this->call('environment:modify', [
|
|
|
|
'key' => $keyname,
|
|
|
|
'value' => $value
|
|
|
|
]);
|
|
|
|
}
|
2020-07-09 03:52:53 +00:00
|
|
|
|
2021-10-13 00:47:16 +00:00
|
|
|
$this->info('>> Saved configuration settings!');
|
|
|
|
$this->info('>> Preparing database...');
|
|
|
|
|
|
|
|
$this->callSilent('config:cache');
|
|
|
|
$this->call('migrate');
|
|
|
|
$this->call('db:seed');
|
|
|
|
|
|
|
|
touch($basePath . '/INSTALLED');
|
|
|
|
|
|
|
|
$this->call('up');
|
|
|
|
$this->info('>> All done! Visit ' . $basePath . ' to start using your brand new installation of Raspberry Teams!');
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->error('[!] The application is already installed!');
|
2020-07-09 03:52:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|