forked from engineering/cloudservices
Changes to path location
parent
4c0d5cad32
commit
8e7a641c7b
|
@ -119,8 +119,8 @@ export default class Client extends Eris.Client {
|
||||||
});
|
});
|
||||||
this.server = new Server(this, { port: this.config.port });
|
this.server = new Server(this, { port: this.config.port });
|
||||||
|
|
||||||
const corepath = '/var/CloudServices/dist';
|
const corepath = '/opt/CloudServices/dist';
|
||||||
const cmdFiles = await fs.readdir('/var/CloudServices/dist/commands');
|
const cmdFiles = await fs.readdir('/opt/CloudServices/dist/commands');
|
||||||
cmdFiles.forEach((f) => delete require.cache[`${corepath}/${f}`]);
|
cmdFiles.forEach((f) => delete require.cache[`${corepath}/${f}`]);
|
||||||
delete require.cache[`${corepath}/config.json`];
|
delete require.cache[`${corepath}/config.json`];
|
||||||
delete require.cache[`${corepath}/class/Util`];
|
delete require.cache[`${corepath}/class/Util`];
|
||||||
|
|
|
@ -150,7 +150,7 @@ export default class CWG_Create extends Command {
|
||||||
if (x509Certificate) {
|
if (x509Certificate) {
|
||||||
x509 = await this.createCertAndPrivateKey(domain, x509Certificate.cert, x509Certificate.key);
|
x509 = await this.createCertAndPrivateKey(domain, x509Certificate.cert, x509Certificate.key);
|
||||||
}
|
}
|
||||||
let cfg = await fs.readFile('/var/CloudServices/dist/static/nginx.conf', { encoding: 'utf8' });
|
let cfg = await fs.readFile('/opt/CloudServices/dist/static/nginx.conf', { encoding: 'utf8' });
|
||||||
cfg = cfg.replace(/\[DOMAIN]/g, domain);
|
cfg = cfg.replace(/\[DOMAIN]/g, domain);
|
||||||
cfg = cfg.replace(/\[PORT]/g, String(port));
|
cfg = cfg.replace(/\[PORT]/g, String(port));
|
||||||
cfg = cfg.replace(/\[CERTIFICATE]/g, x509.cert);
|
cfg = cfg.replace(/\[CERTIFICATE]/g, x509.cert);
|
||||||
|
@ -185,7 +185,7 @@ export default class CWG_Create extends Command {
|
||||||
public async createCertAndPrivateKey(domain: string, certChain: string, privateKey: string) {
|
public async createCertAndPrivateKey(domain: string, certChain: string, privateKey: string) {
|
||||||
if (!this.isValidCertificateChain(certChain)) throw new Error('Invalid Certificate Chain');
|
if (!this.isValidCertificateChain(certChain)) throw new Error('Invalid Certificate Chain');
|
||||||
if (!this.isValidPrivateKey(privateKey)) throw new Error('Invalid Private Key');
|
if (!this.isValidPrivateKey(privateKey)) throw new Error('Invalid Private Key');
|
||||||
const path = `/var/CloudServices/temp/${domain}`;
|
const path = `/opt/CloudServices/temp/${domain}`;
|
||||||
const temp = [writeFile(`${path}.chain.crt`, certChain), writeFile(`${path}.key.pem`, privateKey)];
|
const temp = [writeFile(`${path}.chain.crt`, certChain), writeFile(`${path}.key.pem`, privateKey)];
|
||||||
const removeFiles = [unlink(`${path}.chain.crt`), unlink(`${path}.key.pem`)];
|
const removeFiles = [unlink(`${path}.chain.crt`), unlink(`${path}.key.pem`)];
|
||||||
await Promise.all(temp);
|
await Promise.all(temp);
|
||||||
|
|
|
@ -32,7 +32,7 @@ export default class CWG_UpdateCert extends Command {
|
||||||
if (!this.isValidCertificateChain(certAndPrivateKey[0])) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid Certificate Chain***`);
|
if (!this.isValidCertificateChain(certAndPrivateKey[0])) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid Certificate Chain***`);
|
||||||
if (!this.isValidPrivateKey(certAndPrivateKey[1])) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid Private Key***`);
|
if (!this.isValidPrivateKey(certAndPrivateKey[1])) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid Private Key***`);
|
||||||
|
|
||||||
const path = `/var/CloudServices/temp/${account.id}`;
|
const path = `/opt/CloudServices/temp/${account.id}`;
|
||||||
const temp = [writeFile(`${path}.chain.crt`, certAndPrivateKey[0]), writeFile(`${path}.key.pem`, certAndPrivateKey[1])];
|
const temp = [writeFile(`${path}.chain.crt`, certAndPrivateKey[0]), writeFile(`${path}.key.pem`, certAndPrivateKey[1])];
|
||||||
const removeFiles = [unlink(`${path}.chain.crt`), unlink(`${path}.key.pem`)];
|
const removeFiles = [unlink(`${path}.chain.crt`), unlink(`${path}.key.pem`)];
|
||||||
await Promise.all(temp);
|
await Promise.all(temp);
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default class Exec extends Command {
|
||||||
const response = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Executing \`${args.join(' ')}\`***`);
|
const response = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Executing \`${args.join(' ')}\`***`);
|
||||||
let result: string;
|
let result: string;
|
||||||
try {
|
try {
|
||||||
result = await this.client.util.exec(args.join(' '), { cwd: '/var/CloudServices' });
|
result = await this.client.util.exec(args.join(' '), { cwd: '/opt/CloudServices' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
result = error.message;
|
result = error.message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ export default class Load extends Command {
|
||||||
const type = args[0].toLowerCase();
|
const type = args[0].toLowerCase();
|
||||||
if (!allowed.includes(type)) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid type to (re)load***`);
|
if (!allowed.includes(type)) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid type to (re)load***`);
|
||||||
|
|
||||||
const corepath = '/var/CloudServices/dist';
|
const corepath = '/opt/CloudServices/dist';
|
||||||
if (type === 'config') {
|
if (type === 'config') {
|
||||||
this.client.config = require(`${corepath}/config.json`);
|
this.client.config = require(`${corepath}/config.json`);
|
||||||
delete require.cache[`${corepath}/config.json`];
|
delete require.cache[`${corepath}/config.json`];
|
||||||
|
|
|
@ -20,7 +20,7 @@ export default class Pull extends Command {
|
||||||
let pull: string;
|
let pull: string;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pull = await this.client.util.exec('git pull', { cwd: '/var/CloudServices' });
|
pull = await this.client.util.exec('git pull', { cwd: '/opt/CloudServices' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const updatedMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.error} ***Could not fetch latest commit***`)
|
const updatedMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.error} ***Could not fetch latest commit***`)
|
||||||
.replace(/```$/, `${error.message}\n\`\`\``);
|
.replace(/```$/, `${error.message}\n\`\`\``);
|
||||||
|
@ -46,7 +46,7 @@ export default class Pull extends Command {
|
||||||
|
|
||||||
let install: string;
|
let install: string;
|
||||||
try {
|
try {
|
||||||
install = await this.client.util.exec('yarn install', { cwd: '/var/CloudServices' });
|
install = await this.client.util.exec('yarn install', { cwd: '/opt/CloudServices' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.client.updating = false;
|
this.client.updating = false;
|
||||||
const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.error} ***Failed to reinstall dependencies***`)
|
const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.error} ***Failed to reinstall dependencies***`)
|
||||||
|
@ -71,7 +71,7 @@ export default class Pull extends Command {
|
||||||
|
|
||||||
let build: string;
|
let build: string;
|
||||||
try {
|
try {
|
||||||
build = await this.client.util.exec('yarn run build', { cwd: '/var/CloudServices' });
|
build = await this.client.util.exec('yarn run build', { cwd: '/opt/CloudServices' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const updatedMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.error} ***Failed to rebuild files***`)
|
const updatedMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.error} ***Failed to rebuild files***`)
|
||||||
.replace(/```$/, `${error.message}\n\`\`\``);
|
.replace(/```$/, `${error.message}\n\`\`\``);
|
||||||
|
|
|
@ -11,8 +11,8 @@ export default async function storage(client: Client) {
|
||||||
const res = await client.util.exec(`du -bs /home/${account.username}`);
|
const res = await client.util.exec(`du -bs /home/${account.username}`);
|
||||||
let bytes = Number(res.split('/')[0].replace('\t', ''));
|
let bytes = Number(res.split('/')[0].replace('\t', ''));
|
||||||
try {
|
try {
|
||||||
await fs.access(`/var/mail/${account.username}`, fs.constants.F_OK);
|
await fs.access(`/opt/mail/${account.username}`, fs.constants.F_OK);
|
||||||
const res2 = await client.util.exec(`du -bs /var/mail/${account.username}`);
|
const res2 = await client.util.exec(`du -bs /opt/mail/${account.username}`);
|
||||||
bytes += Number(res2.split('/')[0].replace('\t', ''));
|
bytes += Number(res2.split('/')[0].replace('\t', ''));
|
||||||
} catch {
|
} catch {
|
||||||
bytes += 0;
|
bytes += 0;
|
||||||
|
|
Loading…
Reference in New Issue