add create database configuration file task
This commit is contained in:
parent
672e3bca67
commit
c98b0ab3f2
26
deploy.php
26
deploy.php
@ -65,3 +65,29 @@ task('migrate:setShopsOnline', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
desc('create database coniguration file');
|
||||||
|
task('setup:createDbConfig', function () {
|
||||||
|
try {
|
||||||
|
if (!has('db_conf_path') || !strlen(get('db_conf_path'))) {
|
||||||
|
throw new \RuntimeException('missing db_conf_path option, task stopped');
|
||||||
|
}
|
||||||
|
if (!test('[ -d $(dirname "{{db_conf_path}}") ]')) {
|
||||||
|
throw new \RuntimeException('configured path {{db_conf_path}} missing, task stopped');
|
||||||
|
}
|
||||||
|
if (!test("[ -f {{db_conf_path}} ]")) {
|
||||||
|
run("touch {{db_conf_path}}");
|
||||||
|
}
|
||||||
|
if (test("[ -f {{db_conf_path}} ]")) {
|
||||||
|
$db_host = ask('database host', 'localhost');
|
||||||
|
$db_port = ask('database port', '3306');
|
||||||
|
$db_user = ask('database user');
|
||||||
|
$db_pass = askHiddenResponse('database password');
|
||||||
|
run('printf "[mysql]\nuser='.$db_user.'\npassword=\"'.$db_pass.'\"\nhost='.$db_host.'\nport='.$db_port.'\n\n[mysqldump]\nuser='.$db_user.'\npassword=\"'.$db_pass.'\"\nhost='.$db_host.'\nport='.$db_port.'" > {{db_conf_path}}');
|
||||||
|
info('config successful created');
|
||||||
|
} else {
|
||||||
|
throw new \RuntimeException('can not create {{db_conf_path}}, task stopped');
|
||||||
|
}
|
||||||
|
} catch(\RuntimeException $e) {
|
||||||
|
warning($e->getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
@ -9,7 +9,7 @@ config:
|
|||||||
.base: &base
|
.base: &base
|
||||||
local: true
|
local: true
|
||||||
deploy_path: /home/XXX/{{application}}_{{alias}}
|
deploy_path: /home/XXX/{{application}}_{{alias}}
|
||||||
db_conf_path: /home/XXX/dbConf/my_{{alias}}.cnf # optional for database actions
|
db_conf_path: /home/XXX/dbConf/.my_{{alias}}.cnf # optional for database actions
|
||||||
shared_files:
|
shared_files:
|
||||||
- .htaccess
|
- .htaccess
|
||||||
- .htpasswd
|
- .htpasswd
|
||||||
|
Loading…
Reference in New Issue
Block a user