mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-17 12:33:06 +00:00
update
This commit is contained in:
@@ -94,11 +94,20 @@ async function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function reEncryptSecrets() {
|
async function reEncryptSecrets() {
|
||||||
|
const { execaCommand } = await import('execa');
|
||||||
|
await execaCommand('env | grep COOLIFY > .env', { shell: true });
|
||||||
const secretOld = process.env['COOLIFY_SECRET_KEY'];
|
const secretOld = process.env['COOLIFY_SECRET_KEY'];
|
||||||
const secretNew = process.env['COOLIFY_SECRET_KEY_BETTER'];
|
let secretNew = process.env['COOLIFY_SECRET_KEY_BETTER'];
|
||||||
if (!secretNew) {
|
if (!secretNew) {
|
||||||
console.log('no new secret found');
|
console.log('no new secret found, generating new one');
|
||||||
return;
|
const { stdout: newKey } = await execaCommand(
|
||||||
|
'openssl rand -base64 1024 | sha256sum | base64 | head -c 32',
|
||||||
|
{ shell: true }
|
||||||
|
);
|
||||||
|
await execaCommand('echo "COOLIFY_SECRET_KEY_BETTER=' + newKey + '" >> .env ', { shell: true });
|
||||||
|
await execaCommand(`sed -i '/COOLIFY_SECRET_KEY=/d' .env`, { shell: true });
|
||||||
|
await execaCommand(`echo "COOLIFY_SECRET_KEY=${newKey}" >> .env`, { shell: true });
|
||||||
|
secretNew = newKey;
|
||||||
}
|
}
|
||||||
if (secretOld !== secretNew) {
|
if (secretOld !== secretNew) {
|
||||||
console.log('secrets are different, so re-encrypting');
|
console.log('secrets are different, so re-encrypting');
|
||||||
@@ -113,6 +122,8 @@ async function reEncryptSecrets() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log('secrets are the same, so no need to re-encrypt');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ export async function update(request: FastifyRequest<Update>) {
|
|||||||
await executeCommand({ command: `docker pull ${image}` });
|
await executeCommand({ command: `docker pull ${image}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
await executeCommand({ shell: true, command: `env | grep COOLIFY > .env` });
|
await executeCommand({ shell: true, command: `ls .env || env | grep COOLIFY > .env` });
|
||||||
await executeCommand({
|
await executeCommand({
|
||||||
command: `sed -i '/COOLIFY_AUTO_UPDATE=/cCOOLIFY_AUTO_UPDATE=${isAutoUpdateEnabled}' .env`
|
command: `sed -i '/COOLIFY_AUTO_UPDATE=/cCOOLIFY_AUTO_UPDATE=${isAutoUpdateEnabled}' .env`
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user