Skip to content

Commit

Permalink
Merge pull request #137 from butcherman/laravel9test
Browse files Browse the repository at this point in the history
Laravel9test
  • Loading branch information
butcherman committed May 21, 2022
2 parents 201eca1 + ea45260 commit 01f3879
Show file tree
Hide file tree
Showing 50 changed files with 2,786 additions and 1,279 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/vendor
/tests/_report
/keystore
/packages
.vscode/
.env
.env.backup
Expand All @@ -16,3 +17,4 @@ npm-debug.log
yarn-error.log
modules_statuses.json
public/mix-manifest.json
version.txt
40 changes: 0 additions & 40 deletions app/Console/Commands/TbBackupCommand.php

This file was deleted.

58 changes: 58 additions & 0 deletions app/Console/Commands/TbMaintenanceBackupCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class TbMaintenanceBackupCommand extends Command
{
protected $signature = 'tb_maintenance:backup
{--databaseOnly : Only backup the configuration database}
{--filesOnly : Only backup the file system}';
protected $description = 'Generate a backup of the Tech Bench application';

/**
* Execute the console command
*/
public function handle()
{
$this->line('Starting Application Backup');
$this->line('Please wait...');

Log::info('Starting Application Backup');

// Verify that no more than 70% of the HDD storage space has been used
$freeSpace = disk_free_space('/app');
$totalSpace = disk_total_space('/app');
$usedSpace = $totalSpace - $freeSpace;
$percentage = round(($usedSpace / $totalSpace * 100), 2);

if($percentage > 70)
{
Log::critical('Unable to backup file system, more than 70% of the available storage space in use');
$this->error('More than 70% of the file system is in use. Unable to backup file system at this time');
$this->error('Only backing up database ');
$this->call('backup:run', ['--only-db' => true]);
return 0;
}

if($this->option('databaseOnly'))
{
$this->call('backup:run', ['--only-db' => true]);
}
elseif($this->option('filesOnly'))
{
$this->call('backup:run', ['--only-files' => true]);
}
else
{
$this->call('backup:run');
}

Log::info('Application backup completed');
$this->info('Backup successful');

return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;

class TbBackupDefaultCommand extends Command
class TbMaintenanceDefaultCommand extends Command
{
protected $signature = 'tb_backup:default {--confirmed} {--demo}';
protected $signature = 'tb_backup:default
{--confirmed : Run command without verification}
{--demo : Populate the database with random data for demonstration purpose}';
protected $description = 'Completely wipe all Tech Bench data and start from scratch';

/**
* Create a new command instance
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command
*/
Expand All @@ -36,6 +30,8 @@ public function handle()
return 0;
}

$this->warn('Defaulting Tech Bench');
$this->warn('Please wait...');
$this->call('down');
$this->callSilently('migrate:fresh');
$this->wipeFiles();
Expand All @@ -47,6 +43,7 @@ public function handle()
$this->callSilently('storage:link');

$this->info('Operation complete');
$this->info('You can log into the Tech Bench with the default username `admin` and default password `password`');
$this->call('up');
return 0;
}
Expand Down
Loading

0 comments on commit 01f3879

Please sign in to comment.