diff --git a/src/commands/cwg_create.ts b/src/commands/cwg_create.ts index 1513676..84e05b2 100644 --- a/src/commands/cwg_create.ts +++ b/src/commands/cwg_create.ts @@ -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` }; }