shell: no need to promise scoping

This commit is contained in:
Girish Ramakrishnan
2024-02-21 19:40:27 +01:00
parent cfd5c0f82b
commit a6f078330f
20 changed files with 105 additions and 107 deletions
+4 -4
View File
@@ -34,7 +34,7 @@ async function ensureKeys() {
debug(`ensureSecrets: generating new sftp keys of type ${keyType}`);
safe.fs.unlinkSync(publicKeyFile);
safe.fs.unlinkSync(privateKeyFile);
const [error] = await safe(shell.promises.exec('ensureKeys', `ssh-keygen -m PEM -t ${keyType} -f "${paths.SFTP_KEYS_DIR}/ssh_host_${keyType}_key" -q -N ""`, {}));
const [error] = await safe(shell.exec('ensureKeys', `ssh-keygen -m PEM -t ${keyType} -f "${paths.SFTP_KEYS_DIR}/ssh_host_${keyType}_key" -q -N ""`, {}));
if (error) throw new BoxError(BoxError.OPENSSL_ERROR, `Could not generate sftp ${keyType} keys: ${error.message}`);
const newPublicKey = safe.fs.readFileSync(publicKeyFile);
await blobs.set(`sftp_${keyType}_public_key`, newPublicKey);
@@ -123,9 +123,9 @@ async function start(existingInfra) {
${readOnly} -v /tmp -v /run "${image}" ${cmd}`;
// ignore error if container not found (and fail later) so that this code works across restarts
await safe(shell.promises.exec('stopSftp', 'docker stop sftp', {})); // ignore error
await safe(shell.promises.exec('removeSftp', 'docker rm -f sftp', {})); // ignore error
await shell.promises.exec('startSftp', runCmd, {});
await safe(shell.exec('stopSftp', 'docker stop sftp', {})); // ignore error
await safe(shell.exec('removeSftp', 'docker rm -f sftp', {})); // ignore error
await shell.exec('startSftp', runCmd, {});
}
async function status() {