Cachet is now a Laravel 5 app
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Console\Commands;
|
||||
|
||||
use DirectoryIterator;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class FixPermissionsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'cachet:chmod';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Fixes file and directory permissions. Ensures SQLite database is writeable.';
|
||||
|
||||
/**
|
||||
* Path to the storage directory.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $storageDirectory;
|
||||
|
||||
/**
|
||||
* Path of the database directory.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $databaseDirectory;
|
||||
|
||||
/**
|
||||
* Path of the SQLite database file.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $databasePath;
|
||||
|
||||
/**
|
||||
* Which database connection are we using?
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $databaseDefault;
|
||||
|
||||
/**
|
||||
* Create a new fix permissions command instance.
|
||||
*
|
||||
* @param string $storageDirectory
|
||||
* @param string $databaseDirectory
|
||||
* @param string $databasePath
|
||||
* @param string $databaseDefault
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($storageDirectory, $databaseDirectory, $databasePath, $databaseDefault)
|
||||
{
|
||||
$this->storageDirectory = $storageDirectory;
|
||||
$this->databaseDirectory = $databaseDirectory;
|
||||
$this->databasePath = $databasePath;
|
||||
$this->databaseDefault = $databaseDefault;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$this->recursiveChmod($this->storageDirectory);
|
||||
|
||||
if ($this->databaseDefault === 'sqlite') {
|
||||
chmod($this->databaseDirectory, 755);
|
||||
chmod($this->databasePath, 755);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively sets a paths file permissions.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $mode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function recursiveChmod($path, $mode = '0755')
|
||||
{
|
||||
$dir = new DirectoryIterator($path);
|
||||
foreach ($dir as $item) {
|
||||
if (!$item->isDot()) {
|
||||
chmod($item->getPathname(), $mode);
|
||||
}
|
||||
|
||||
if ($item->isDir() && !$item->isDot()) {
|
||||
$this->recursiveChmod($item->getPathname());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class OneClickDeployCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'cachet:one-click-deploy';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Installs CachetHQ on one click supported services';
|
||||
|
||||
/**
|
||||
* Should we run the migrations?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $migrate;
|
||||
|
||||
/**
|
||||
* Create a new one click deploy command instance.
|
||||
*
|
||||
* @param bool $migrate
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($migrate)
|
||||
{
|
||||
$this->migrate = $migrate;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
if ($this->migrate) {
|
||||
$migrations = $this->runMigrations();
|
||||
|
||||
segment_track('Installation', [
|
||||
'event' => 'Heroku Deployment',
|
||||
]);
|
||||
|
||||
return $migrations;
|
||||
}
|
||||
|
||||
$this->info('Please run "php artisan migrate" to finish the installation.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function runMigrations()
|
||||
{
|
||||
$options = [
|
||||
'--database' => $this->input->getOption('database'),
|
||||
'--force' => $this->input->getOption('force'),
|
||||
'--seed' => $this->input->getOption('seed'),
|
||||
];
|
||||
|
||||
return $this->call('migrate', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
|
||||
['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
'CachetHQ\Cachet\Console\Commands\FixPermissionsCommand',
|
||||
'CachetHQ\Cachet\Console\Commands\OneClickDeployCommand',
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user