symlink cloud certs instead of writing

pull/15/head
Matthew 2021-11-28 15:20:55 -05:00
parent 7e20b362c3
commit 8e9b260481
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import fs, { writeFile, unlink } from 'fs-extra';
import fs, { writeFile, unlink, symlink } from 'fs-extra';
import axios from 'axios';
import { randomBytes } from 'crypto';
import { Message, MessageEmbed, TextChannel } from 'discord.js';
@ -190,7 +190,11 @@ export default class CWG_Create extends Command {
throw new Error('Certificate and Private Key do not match');
}
await Promise.all([writeFile(`/etc/ssl/certs/cwg/${domain}.chain.crt`, certChain), writeFile(`/etc/ssl/private/cwg/${domain}.key.pem`, privateKey)]);
if (domain.endsWith('.cloud.libraryofcode.org')) {
await Promise.all([symlink('/etc/ssl/private/cloud-libraryofcode-org.chain.crt', `/etc/ssl/certs/cwg/${domain}.chain.crt`), symlink('/etc/ssl/private/cloud-libraryofcode-org.key', `/etc/ssl/private/cwg/${domain}.key.pem`)]);
} else {
await Promise.all([writeFile(`/etc/ssl/certs/cwg/${domain}.chain.crt`, certChain), writeFile(`/etc/ssl/private/cwg/${domain}.key.pem`, privateKey)]);
}
return { cert: `/etc/ssl/certs/cwg/${domain}.chain.crt`, key: `/etc/ssl/private/cwg/${domain}.key.pem` };
}