shell: exec encoding is utf8 by default and no shell

explicitly mark calls that require the shell
This commit is contained in:
Girish Ramakrishnan
2024-02-21 17:16:33 +01:00
parent 23cac99fe9
commit 14c9260ab0
14 changed files with 54 additions and 51 deletions
+5 -5
View File
@@ -49,7 +49,7 @@ async function pruneInfraImages() {
// cannot blindly remove all unused images since redis image may not be used
const imageNames = Object.keys(infra.images).map(addon => infra.images[addon]);
const [error, output] = await safe(shell.promises.exec('pruneInfraImages', 'docker images --digests --format "{{.ID}} {{.Repository}} {{.Tag}} {{.Digest}}"', { encoding: 'utf8' }));
const [error, output] = await safe(shell.promises.exec('pruneInfraImages', 'docker images --digests --format "{{.ID}} {{.Repository}} {{.Tag}} {{.Digest}}"', {}));
if (error) {
debug(`Failed to list images ${error.message}`);
throw error;
@@ -69,7 +69,7 @@ async function pruneInfraImages() {
const imageIdToPrune = tag === '<none>' ? `${repo}@${digest}` : `${repo}:${tag}`; // untagged, use digest
console.log(`pruneInfraImages: removing unused image of ${imageName}: ${imageIdToPrune}`);
const [error] = await safe(shell.promises.exec('pruneInfraImages', `docker rmi '${imageIdToPrune}'`, { encoding: 'utf8' }));
const [error] = await safe(shell.promises.exec('pruneInfraImages', `docker rmi '${imageIdToPrune}'`, {}));
if (error) console.log(`Error removing image ${imageIdToPrune}: ${error.mesage}`);
}
}
@@ -78,7 +78,7 @@ async function pruneInfraImages() {
async function createDockerNetwork() {
debug('createDockerNetwork: recreating docker network');
await shell.promises.exec('createDockerNetwork', 'docker network rm cloudron || true', {});
await safe(shell.promises.exec('createDockerNetwork', 'docker network rm cloudron', {})); // ignore error
// the --ipv6 option will work even in ipv6 is disabled. fd00 is IPv6 ULA
await shell.promises.exec('createDockerNetwork', `docker network create --subnet=${constants.DOCKER_IPv4_SUBNET} --ip-range=${constants.DOCKER_IPv4_RANGE} --gateway ${constants.DOCKER_IPv4_GATEWAY} --ipv6 --subnet=fd00:c107:d509::/64 cloudron`, {});
}
@@ -86,8 +86,8 @@ async function createDockerNetwork() {
async function removeAllContainers() {
debug('removeAllContainers: removing all containers for infra upgrade');
await shell.promises.exec('removeAllContainers', 'docker ps -qa --filter \'label=isCloudronManaged\' | xargs --no-run-if-empty docker stop', {});
await shell.promises.exec('removeAllContainers', 'docker ps -qa --filter \'label=isCloudronManaged\' | xargs --no-run-if-empty docker rm -f', {});
await shell.promises.exec('removeAllContainers', 'docker ps -qa --filter \'label=isCloudronManaged\' | xargs --no-run-if-empty docker stop', { shell: '/bin/bash' });
await shell.promises.exec('removeAllContainers', 'docker ps -qa --filter \'label=isCloudronManaged\' | xargs --no-run-if-empty docker rm -f', { shell: '/bin/bash' });
}
async function markApps(existingInfra, restoreOptions) {