fixup various shell usage
This commit is contained in:
@@ -31,6 +31,7 @@ const assert = require('assert'),
|
||||
docker = require('./docker.js'),
|
||||
domains = require('./domains.js'),
|
||||
eventlog = require('./eventlog.js'),
|
||||
fs = require('fs'),
|
||||
hat = require('./hat.js'),
|
||||
infra = require('./infra_version.js'),
|
||||
Location = require('./location.js'),
|
||||
@@ -153,7 +154,9 @@ async function configureMail(mailFqdn, mailDomain, serviceConfig) {
|
||||
const mailCertFilePath = `${paths.MAIL_CONFIG_DIR}/tls_cert.pem`;
|
||||
const mailKeyFilePath = `${paths.MAIL_CONFIG_DIR}/tls_key.pem`;
|
||||
|
||||
const [copyError] = await safe(shell.exec('configureMail', `cp ${paths.DHPARAMS_FILE} ${dhparamsFilePath}`, {}));
|
||||
const [readError, dhparams] = await safe(fs.promises.readFile(paths.DHPARAMS_FILE));
|
||||
if (readError) throw new BoxError(BoxError.FS_ERROR, `Could not read dhparams: ${readError.message}`);
|
||||
const [copyError] = await safe(fs.promises.writeFile(dhparamsFilePath, dhparams));
|
||||
if (copyError) throw new BoxError(BoxError.FS_ERROR, `Could not copy dhparams: ${copyError.message}`);
|
||||
if (!safe.fs.writeFileSync(mailCertFilePath, certificate.cert)) throw new BoxError(BoxError.FS_ERROR, `Could not create cert file: ${safe.error.message}`);
|
||||
if (!safe.fs.writeFileSync(mailKeyFilePath, certificate.key)) throw new BoxError(BoxError.FS_ERROR, `Could not create key file: ${safe.error.message}`);
|
||||
@@ -161,8 +164,9 @@ async function configureMail(mailFqdn, mailDomain, serviceConfig) {
|
||||
// if the 'yellowtent' user of OS and the 'cloudron' user of mail container don't match, the keys become inaccessible by mail code
|
||||
if (!safe.fs.chmodSync(mailKeyFilePath, 0o644)) throw new BoxError(BoxError.FS_ERROR, `Could not chmod key file: ${safe.error.message}`);
|
||||
|
||||
await safe(shell.exec('stopMail', 'docker stop mail', {})); // ignore error
|
||||
await safe(shell.exec('removeMail', 'docker rm -f mail', {})); // ignore error
|
||||
debug('configureMail: stopping and deleting previous mail container');
|
||||
await docker.stopContainer('mail');
|
||||
await docker.deleteContainer('mail');
|
||||
|
||||
const allowInbound = await createMailConfig(mailFqdn);
|
||||
|
||||
@@ -191,7 +195,8 @@ async function configureMail(mailFqdn, mailDomain, serviceConfig) {
|
||||
--label isCloudronManaged=true \
|
||||
${readOnly} -v /run -v /tmp ${image} ${cmd}`;
|
||||
|
||||
await shell.exec('startMail', runCmd, { shell: '/bin/bash' });
|
||||
debug('configureMail: starting mail container');
|
||||
await shell.exec('configureMail', runCmd, { shell: '/bin/bash' });
|
||||
}
|
||||
|
||||
async function restart() {
|
||||
|
||||
Reference in New Issue
Block a user