services: add recoveryMode
This commit is contained in:
@@ -70,8 +70,11 @@ async function start(existingInfra) {
|
||||
if (!resolvedMailDataDir) throw new BoxError(BoxError.FS_ERROR, `Could not resolve mail data dir: ${safe.error.message}`);
|
||||
dataDirs.push({ hostDir: resolvedMailDataDir, mountDir: '/mnt/maildata' });
|
||||
|
||||
const readOnly = !serviceConfig.recoveryMode ? '--read-only' : '';
|
||||
const cmd = serviceConfig.recoveryMode ? '/bin/bash -c \'echo "Debug mode. Sleeping" && sleep infinity\'' : '';
|
||||
|
||||
const mounts = dataDirs.map(v => `-v "${v.hostDir}:${v.mountDir}"`).join(' ');
|
||||
const cmd = `docker run --restart=always -d --name="sftp" \
|
||||
const runCmd = `docker run --restart=always -d --name="sftp" \
|
||||
--hostname sftp \
|
||||
--net cloudron \
|
||||
--net-alias sftp \
|
||||
@@ -88,10 +91,10 @@ async function start(existingInfra) {
|
||||
-e CLOUDRON_SFTP_TOKEN="${cloudronToken}" \
|
||||
-v "${paths.SFTP_KEYS_DIR}:/etc/ssh:ro" \
|
||||
--label isCloudronManaged=true \
|
||||
--read-only -v /tmp -v /run "${tag}"`;
|
||||
${readOnly} -v /tmp -v /run "${tag}" ${cmd}`;
|
||||
|
||||
// ignore error if container not found (and fail later) so that this code works across restarts
|
||||
await shell.promises.exec('stopSftp', 'docker stop sftp || true');
|
||||
await shell.promises.exec('removeSftp', 'docker rm -f sftp || true');
|
||||
await shell.promises.exec('startSftp', cmd);
|
||||
await shell.promises.exec('startSftp', runCmd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user