diff --git a/src/addons.js b/src/addons.js index d084de002..ead972b6f 100644 --- a/src/addons.js +++ b/src/addons.js @@ -369,7 +369,7 @@ function updateAddonConfig(platformConfig, callback) { } const args = `update --memory ${memory} --memory-swap ${memorySwap} ${containerName}`.split(' '); - shell.exec(`update${containerName}`, '/usr/bin/docker', args, { }, iteratorCallback); + shell.spawn(`update${containerName}`, '/usr/bin/docker', args, { }, iteratorCallback); }, callback); } diff --git a/src/docker.js b/src/docker.js index 600c8e8a6..f27b9d5e7 100644 --- a/src/docker.js +++ b/src/docker.js @@ -109,7 +109,7 @@ function pullImage(manifest, callback) { // Use docker CLI here to support downloading of private repos. for dockerode, we have to use // https://github.com/apocas/dockerode#pull-from-private-repos - shell.exec('pullImage', '/usr/bin/docker', [ 'pull', manifest.dockerImage ], { }, function (error) { + shell.spawn('pullImage', '/usr/bin/docker', [ 'pull', manifest.dockerImage ], { }, function (error) { if (error) { debug(`pullImage: Error pulling image ${manifest.dockerImage} of ${manifest.id}: ${error.message}`); return callback(new Error('Failed to pull image')); diff --git a/src/shell.js b/src/shell.js index b2fdfedcc..87dda5e54 100644 --- a/src/shell.js +++ b/src/shell.js @@ -1,7 +1,7 @@ 'use strict'; exports = module.exports = { - exec: exec, + spawn: spawn, execSync: execSync, sudo: sudo, sudoSync: sudoSync @@ -29,7 +29,7 @@ function execSync(tag, cmd, callback) { if (callback) callback(); } -function exec(tag, file, args, options, callback) { +function spawn(tag, file, args, options, callback) { assert.strictEqual(typeof tag, 'string'); assert.strictEqual(typeof file, 'string'); assert(util.isArray(args)); @@ -84,7 +84,7 @@ function sudo(tag, args, options, callback) { assert.strictEqual(typeof options, 'object'); // -S makes sudo read stdin for password. -E preserves environment - var cp = exec(tag, SUDO, [ options.env ? '-SE' : '-S' ].concat(args), options, callback); + var cp = spawn(tag, SUDO, [ options.env ? '-SE' : '-S' ].concat(args), options, callback); cp.stdin.end(); return cp; } diff --git a/src/storage/filesystem.js b/src/storage/filesystem.js index d95b1d30e..9c64d46ce 100644 --- a/src/storage/filesystem.js +++ b/src/storage/filesystem.js @@ -120,7 +120,7 @@ function copy(apiConfig, oldFilePath, newFilePath) { // this will hardlink backups saving space var cpOptions = apiConfig.noHardlinks ? '-a' : '-al'; - shell.exec('copy', '/bin/cp', [ cpOptions, oldFilePath, newFilePath ], { }, function (error) { + shell.spawn('copy', '/bin/cp', [ cpOptions, oldFilePath, newFilePath ], { }, function (error) { if (error) return events.emit('done', new BackupsError(BackupsError.EXTERNAL_ERROR, error.message)); events.emit('done', null); @@ -155,7 +155,7 @@ function removeDir(apiConfig, pathPrefix) { events.emit('progress', `removeDir: ${pathPrefix}`); - shell.exec('removeDir', '/bin/rm', [ '-rf', pathPrefix ], { }, function (error) { + shell.spawn('removeDir', '/bin/rm', [ '-rf', pathPrefix ], { }, function (error) { if (error) return events.emit('done', new BackupsError(BackupsError.EXTERNAL_ERROR, error.message)); events.emit('done', null); diff --git a/src/test/shell-test.js b/src/test/shell-test.js index 9ffbee28c..b371746c8 100644 --- a/src/test/shell-test.js +++ b/src/test/shell-test.js @@ -12,7 +12,7 @@ var expect = require('expect.js'), describe('shell', function () { it('can run valid program', function (done) { - var cp = shell.exec('test', 'ls', [ '-l' ], { }, function (error) { + var cp = shell.spawn('test', 'ls', [ '-l' ], { }, function (error) { expect(cp).to.be.ok(); expect(error).to.be(null); done(); @@ -20,14 +20,14 @@ describe('shell', function () { }); it('fails on invalid program', function (done) { - var cp = shell.exec('test', 'randomprogram', [ ], { }, function (error) { + var cp = shell.spawn('test', 'randomprogram', [ ], { }, function (error) { expect(error).to.be.ok(); done(); }); }); it('fails on failing program', function (done) { - var cp = shell.exec('test', '/usr/bin/false', [ ], { }, function (error) { + var cp = shell.spawn('test', '/usr/bin/false', [ ], { }, function (error) { expect(error).to.be.ok(); done(); }); diff --git a/src/updater.js b/src/updater.js index 80cacadc7..1657c50cd 100644 --- a/src/updater.js +++ b/src/updater.js @@ -75,7 +75,7 @@ function downloadUrl(url, file, callback) { debug(`downloadUrl: curl ${args}`); - shell.exec('downloadUrl', '/usr/bin/curl', args.split(' '), { }, function (error) { + shell.spawn('downloadUrl', '/usr/bin/curl', args.split(' '), { }, function (error) { if (error) return retryCallback(new UpdaterError(UpdaterError.EXTERNAL_ERROR, `Failed to download ${url}: ${error.message}`)); debug(`downloadUrl: downloadUrl ${url} to ${file}`); @@ -106,7 +106,7 @@ function extractTarball(tarball, dir, callback) { debug(`extractTarball: tar ${args}`); - shell.exec('extractTarball', '/bin/tar', args.split(' '), { }, function (error) { + shell.spawn('extractTarball', '/bin/tar', args.split(' '), { }, function (error) { if (error) return callback(new UpdaterError(UpdaterError.EXTERNAL_ERROR, `Failed to extract release package: ${error.message}`)); safe.fs.unlinkSync(tarball);