forked from engineering/cloudservices
Add home path
parent
82b3148fd3
commit
612d527986
|
@ -155,7 +155,7 @@ export default class Util {
|
|||
if (!account) throw new Error('Account not found');
|
||||
this.exec(`lock ${username}`);
|
||||
const tasks = [
|
||||
this.exec(`deluser ${username} --remove-home --backup-to /management/Archives && rm -rf -R /home/${username} && groupdel ${username}`),
|
||||
this.exec(`deluser ${username} --remove-home --backup-to /management/Archives && rm -rf -R ${account.homepath} && groupdel ${account.homepath.replace('/home/', '')}`),
|
||||
this.client.db.Account.deleteOne({ username }),
|
||||
];
|
||||
this.client.removeGuildMemberRole('446067825673633794', account.userID, '546457886440685578', 'Cloud Account Deleted').catch();
|
||||
|
@ -240,7 +240,7 @@ export default class Util {
|
|||
|
||||
public getAcctHash(username: string) {
|
||||
try {
|
||||
return fs.readFileSync(`/home/${username}/.securesign/auth`).toString();
|
||||
return fs.readFileSync(`${username}/.securesign/auth`).toString();
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ export default class DeleteAccount extends Command {
|
|||
if (!args[1]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0] }, { emailAddress: args[0] }] });
|
||||
if (!account) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not found.***`);
|
||||
const { root, username, userID, emailAddress } = account;
|
||||
const { root, username, userID, emailAddress, homepath } = account;
|
||||
if (root) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Permission denied.***`);
|
||||
|
||||
const pad = (number: number, amount: number): string => '0'.repeat(amount - number.toString().length) + number;
|
||||
|
|
|
@ -24,7 +24,7 @@ export default class Disk extends Command {
|
|||
if (account.root || args[0].includes('./')) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Permission denied***`);
|
||||
const diskReply = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Fetching total disk size may up to 10 minutes. This message will edit when the disk size has been located.***`);
|
||||
const start = Date.now();
|
||||
const result = await this.client.util.exec(`du -s /home/${account.username}`);
|
||||
const result = await this.client.util.exec(`du -s ${account.homepath}`);
|
||||
const end = Date.now();
|
||||
// @ts-ignore
|
||||
const totalTime: string = moment.preciseDiff(start, end);
|
||||
|
|
|
@ -20,12 +20,12 @@ export default class Parse extends Command {
|
|||
if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} Cannot find user.***`);
|
||||
let dir: string[];
|
||||
try {
|
||||
dir = await fs.readdir(`/home/${account.username}/Validation`);
|
||||
dir = await fs.readdir(`${account.homepath}/Validation`);
|
||||
} catch (err) {
|
||||
return message.channel.createMessage(`***${this.client.stores.emojis.error} Cannot locate Validation directory.***`);
|
||||
}
|
||||
if (!dir.length) return message.channel.createMessage(`***${this.client.stores.emojis.error} Cannot locate certificate.***`);
|
||||
const cert = parseCert(`/home/${account.username}/Validation/${dir[0]}`);
|
||||
const cert = parseCert(`${account.homepath}/Validation/${dir[0]}`);
|
||||
const subjectCommonName = cert.subject.commonName ? cert.subject.commonName : 'Not Specified';
|
||||
const subjectEmailAddress = cert.subject.emailAddress ? cert.subject.emailAddress : 'Not Specified';
|
||||
const subjectOrganization = cert.subject.organizationName ? cert.subject.organizationName : 'Not Specified';
|
||||
|
@ -39,7 +39,7 @@ export default class Parse extends Command {
|
|||
const user = this.client.users.get(account.userID) ? this.client.users.get(account.userID) : await this.client.getRESTUser(account.userID);
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle('Parse x509 Certificate');
|
||||
embed.setDescription(`/home/${account.username}/Validation/${dir[0]} | ${account.username} <@${user.id}>`);
|
||||
embed.setDescription(`${account.homepath}/Validation/${dir[0]} | ${account.username} <@${user.id}>`);
|
||||
embed.setColor(3447003);
|
||||
embed.addField('Subject', `**Common Name:** ${subjectCommonName}\n**Email Address:** ${subjectEmailAddress}\n**Organization:** ${subjectOrganization}\n**Organizational Unit:** ${subjectOrganizationalUnit}\n**Country:** ${subjectCountry}`, true);
|
||||
embed.addField('Issuer', `**Common Name:** ${issuerCommonName}\n**Email Address:** ${issuerEmailAddress}\n**Organization:** ${issuerOrganization}\n**Organizational Unit:** ${issuerOrganizationalUnit}\n**Country:** ${issuerCountry}`, true);
|
||||
|
|
|
@ -24,13 +24,13 @@ export default class Parseall extends Command {
|
|||
embed.setFooter(`Requested by ${message.member.username}#${message.member.discriminator}`, message.member.avatarURL);
|
||||
embed.setTimestamp();
|
||||
const search = await this.client.db.Account.find();
|
||||
const accounts = search.map((acc) => acc.username);
|
||||
const accounts = search.map((acc) => acc.homepath);
|
||||
const final: string[] = [];
|
||||
|
||||
accounts.forEach(async (a) => {
|
||||
try {
|
||||
const certFile = readdirSync(`/home/${a}/Validation`)[0];
|
||||
const { notAfter } = parseCert(`/home/${a}/Validation/${certFile}`);
|
||||
const certFile = readdirSync(`${a}/Validation`)[0];
|
||||
const { notAfter } = parseCert(`${a}/Validation/${certFile}`);
|
||||
// @ts-ignore
|
||||
const time = moment.preciseDiff(new Date(), notAfter);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ export default class SecureSign_ActivateKey extends Command {
|
|||
if (!account) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not found***`);
|
||||
if (!account.hash) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not initialized***`);
|
||||
const msg = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Activating key...***`);
|
||||
const hash = this.client.util.getAcctHash(account.username);
|
||||
const hash = this.client.util.getAcctHash(account.homepath);
|
||||
try {
|
||||
await axios({
|
||||
method: 'POST',
|
||||
|
|
|
@ -26,7 +26,7 @@ export default class SecureSign_Init extends Command {
|
|||
if (options.m && (!Number(options.m) || (options.m !== '256' && options.m !== '384' && options.m !== '512'))) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid SHA Digest selected, choose between \`256\`, \`384\` or \`512\``);
|
||||
|
||||
const msg = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Creating certificate...***`);
|
||||
const hash = this.client.util.getAcctHash(account.username);
|
||||
const hash = this.client.util.getAcctHash(account.homepath);
|
||||
|
||||
// Check if they can generate certificate
|
||||
try {
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Document, Schema, model } from 'mongoose';
|
|||
export interface AccountInterface extends Document {
|
||||
username: string,
|
||||
userID: string,
|
||||
homepath: string
|
||||
emailAddress: string,
|
||||
createdBy: string,
|
||||
createdAt: Date,
|
||||
|
@ -23,6 +24,7 @@ export interface AccountInterface extends Document {
|
|||
const Account: Schema = new Schema({
|
||||
username: String,
|
||||
userID: String,
|
||||
homepath: String,
|
||||
emailAddress: String,
|
||||
createdBy: String,
|
||||
createdAt: Date,
|
||||
|
|
Loading…
Reference in New Issue