1
|
|
|
<?php |
|
|
|
|
2
|
|
|
namespace App\Shell; |
|
|
|
|
3
|
|
|
|
4
|
|
|
use Cake\Console\Shell; |
5
|
|
|
use Cake\Filesystem\Folder; |
|
|
|
|
6
|
|
|
use Cake\Filesystem\File; |
7
|
|
|
use Cake\Core\Configure; |
8
|
|
|
use Cake\Core\Configure\Engine\PhpConfig; |
|
|
|
|
9
|
|
|
|
10
|
|
|
class InstallShell extends Shell |
|
|
|
|
11
|
|
|
{ |
|
|
|
|
12
|
|
|
|
13
|
|
|
public function main() |
|
|
|
|
14
|
|
|
{ |
|
|
|
|
15
|
|
|
$this->out('FortuneCookies installation'); |
16
|
|
|
$this->hr(); |
17
|
|
|
$this->out('This procedure will output a file called app_local.php'); |
18
|
|
|
$this->out('to store Security Salt and Database connection information'); |
19
|
|
|
|
20
|
|
|
// Salt |
|
|
|
|
21
|
|
|
$this->hr(); |
22
|
|
|
$this->out('Configure Security Salt'); |
23
|
|
|
$this->out('A Security Salt is a random string used to encrypt sensitive data inside this app.'); |
24
|
|
|
$salt = $this->in('Type a string:'); |
25
|
|
|
Configure::write('Security.salt', $salt); |
26
|
|
|
// Database\Connection |
27
|
|
|
// Admin account |
28
|
|
|
// Mail |
|
|
|
|
29
|
|
|
|
30
|
|
|
if(!Configure::read('Security.salt')) |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
$salt = $this->in('Salt:'); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
Configure::write('debug', false); |
36
|
|
|
Configure::write('Datasources.default.className', 'Cake\Database\Connection'); |
37
|
|
|
Configure::write('Datasources.default.driver', 'Cake\Database\Driver\Mysql'); |
38
|
|
|
Configure::write('Datasources.default.persistent', false); |
39
|
|
|
Configure::write('Datasources.default.host', 'localhost'); |
40
|
|
|
Configure::write('Datasources.default.username', 'root'); |
41
|
|
|
Configure::write('Datasources.default.password', 'semaphoredb'); |
42
|
|
|
Configure::write('Datasources.default.database', 'fc_test'); |
43
|
|
|
Configure::write('Datasources.default.encoding', 'utf8'); |
44
|
|
|
Configure::write('Datasources.default.timezone', 'UTC'); |
45
|
|
|
Configure::write('Datasources.default.flags', []); |
46
|
|
|
Configure::write('Datasources.default.cacheMetadata', true); |
47
|
|
|
Configure::write('Datasources.default.log', false); |
48
|
|
|
Configure::write('Datasources.default.quoteIdentifiers', false); |
49
|
|
|
Configure::write('Datasources.default.url', env('DATABASE_URL', null)); |
50
|
|
|
$file = new File('config/app_local.php', false); |
|
|
|
|
51
|
|
|
if(!$file->exists()) { |
|
|
|
|
52
|
|
|
if($ris = Configure::dump('app_local', 'default')) { |
|
|
|
|
53
|
|
|
$this->out("Wrote config file app_local.php"); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
} |
|
|
|
|
56
|
|
|
$file->close(); |
57
|
|
|
} |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|