From 8e9b260481de8e38b36991c1fd029f7cbd2f81b6 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 28 Nov 2021 15:20:55 -0500 Subject: [PATCH] symlink cloud certs instead of writing --- src/commands/cwg_create.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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` }; }