2024-10-30 14:46:31 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Deployer;
|
|
|
|
|
2024-11-01 09:59:25 +01:00
|
|
|
require_once 'inc/database.php';
|
|
|
|
|
2024-11-04 21:55:43 +01:00
|
|
|
desc('create database configuration file');
|
2024-10-30 14:46:31 +01:00
|
|
|
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}}") ]')) {
|
|
|
|
run('mkdir -p $(dirname "{{db_conf_path}}")');
|
|
|
|
if (!test('[ -d $(dirname "{{db_conf_path}}") ]')) {
|
|
|
|
throw new \RuntimeException('unable to create configured path {{db_conf_path}}, task stopped');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!test("[ -f {{db_conf_path}} ]")) {
|
|
|
|
run("touch {{db_conf_path}}");
|
|
|
|
}
|
|
|
|
if (test("[ -f {{db_conf_path}} ]")) {
|
2024-11-06 22:27:08 +01:00
|
|
|
run('printf "[client]\nhost=\"'.ask('database host', 'localhost').'\"\nport=\"'.ask('database port', '3306').'\"\nuser=\"'.ask('database user').'\"\npassword=\"'.askHiddenResponse('database password').'\"\n\n[mysql]\ndatabase=\"'.ask('database name').'\"" > {{db_conf_path}}');
|
2024-10-30 14:46:31 +01:00
|
|
|
info('config successful created');
|
|
|
|
} else {
|
|
|
|
throw new \RuntimeException('can not create {{db_conf_path}}, task stopped');
|
|
|
|
}
|
|
|
|
} catch(\RuntimeException $e) {
|
|
|
|
warning($e->getMessage());
|
|
|
|
}
|
2024-11-01 21:49:52 +01:00
|
|
|
});
|