run method
Runs this command.
The return value is wrapped in a Future
if necessary and returned by
CommandRunner.runCommand
.
Implementation
@override
FutureOr<void> run() async {
stdout.writeln("Running esdbtcli $name...");
final root = Directory(
argResults!['out'] as String,
).absolute.path;
final certs = Directory('$root/certs');
final shell = Shell(workingDirectory: root, runInShell: true);
if (certs.existsSync()) {
stdout.writeln("Deleting ${certs.path}/...");
await chmod(shell, '0755', certs);
await rmdir(shell, certs);
}
await mkdir(shell, certs);
await pull(shell);
await createCa(shell, certs);
await createNode(shell, certs);
await pem(shell, certs);
stdout.writeln(
"Created Certificate Authority certificate at ${certs.path}/ca",
);
await ls(shell, Directory(p.join(certs.path, 'ca')));
stdout.writeln("Created Node certificate at ${certs.path}/node");
await ls(shell, Directory(p.join(certs.path, 'node')));
if (argResults!['secure'] as bool) {
stdout.writeln(
"Limit access to read and write for ${shell.username} only with chmod 0600",
);
await chmod(shell, '0600', certs);
} else {
stdout.writeln(
"Limit access to read and write for ${shell.username} only with chmod 0755",
);
await chmod(shell, '0755', certs);
}
stdout.writeln("Certificates creation finished!");
}