shell: make require take a tag

This commit is contained in:
Girish Ramakrishnan
2024-10-14 19:10:31 +02:00
parent 02823c4158
commit a9e1d7641d
27 changed files with 162 additions and 156 deletions
+3 -3
View File
@@ -14,7 +14,7 @@ const assert = require('assert'),
path = require('path'),
paths = require('./paths.js'),
safe = require('safetydance'),
shell = require('./shell.js');
shell = require('./shell.js')('support');
// the logic here is also used in the cloudron-support tool
const AUTHORIZED_KEYS_CMD = path.join(__dirname, 'scripts/remotesupport.sh');
@@ -34,7 +34,7 @@ function sshInfo() {
}
async function getRemoteSupport() {
const [error, stdoutResult] = await safe(shell.promises.sudo('support', [ AUTHORIZED_KEYS_CMD, 'is-enabled', sshInfo().filePath ], { captureStdout: true }));
const [error, stdoutResult] = await safe(shell.promises.sudo([ AUTHORIZED_KEYS_CMD, 'is-enabled', sshInfo().filePath ], { captureStdout: true }));
if (error) throw new BoxError(BoxError.FS_ERROR, error);
return stdoutResult.trim() === 'true';
@@ -45,7 +45,7 @@ async function enableRemoteSupport(enable, auditSource) {
assert.strictEqual(typeof auditSource, 'object');
const si = sshInfo();
const [error] = await safe(shell.promises.sudo('support', [ AUTHORIZED_KEYS_CMD, enable ? 'enable' : 'disable', si.filePath, si.user ], {}));
const [error] = await safe(shell.promises.sudo([ AUTHORIZED_KEYS_CMD, enable ? 'enable' : 'disable', si.filePath, si.user ], {}));
if (error) throw new BoxError(BoxError.FS_ERROR, error);
await eventlog.add(eventlog.ACTION_SUPPORT_SSH, auditSource, { enable });