1
0
Fork 0

add systemd cat and systemd linger cmd

refactor/models
Matthew 2020-06-28 22:10:50 -04:00
parent a43de64957
commit f8d466686d
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
3 changed files with 92 additions and 31 deletions

View File

@ -1,31 +1,32 @@
export { default as announce } from './announce'; export { default as announce } from './announce';
export { default as bearer } from './bearer'; export { default as bearer } from './bearer';
export { default as cloudflare } from './cloudflare'; export { default as cloudflare } from './cloudflare';
export { default as createaccount } from './createaccount'; export { default as createaccount } from './createaccount';
export { default as cwg } from './cwg'; export { default as cwg } from './cwg';
export { default as deleteaccount } from './deleteaccount'; export { default as deleteaccount } from './deleteaccount';
export { default as disk } from './disk'; export { default as disk } from './disk';
export { default as emailcode } from './emailcode'; export { default as emailcode } from './emailcode';
export { default as eval } from './eval'; export { default as eval } from './eval';
export { default as exec } from './exec'; export { default as exec } from './exec';
export { default as help } from './help'; export { default as help } from './help';
export { default as limits } from './limits'; export { default as limits } from './limits';
export { default as load } from './load'; export { default as load } from './load';
export { default as lock } from './lock'; export { default as lock } from './lock';
export { default as modlogs } from './modlogs'; export { default as modlogs } from './modlogs';
export { default as notify } from './notify'; export { default as notify } from './notify';
export { default as parse } from './parse'; export { default as parse } from './parse';
export { default as parseall } from './parseall'; export { default as parseall } from './parseall';
export { default as ping } from './ping'; export { default as ping } from './ping';
export { default as pull } from './pull'; export { default as pull } from './pull';
export { default as resetpassword } from './resetpassword'; export { default as resetpassword } from './resetpassword';
export { default as restart } from './restart'; export { default as restart } from './restart';
export { default as securesign } from './securesign'; export { default as securesign } from './securesign';
export { default as setlimit } from './setlimit'; export { default as setlimit } from './setlimit';
export { default as sysinfo } from './sysinfo'; export { default as sysinfo } from './sysinfo';
export { default as tier } from './tier'; export { default as systemd } from './systemd';
export { default as unban } from './unban'; export { default as tier } from './tier';
export { default as unlock } from './unlock'; export { default as unban } from './unban';
export { default as warn } from './warn'; export { default as unlock } from './unlock';
export { default as whois } from './whois'; export { default as warn } from './warn';
export { default as whoisold } from './whoisold'; export { default as whois } from './whois';
export { default as whoisold } from './whoisold';

23
src/commands/systemd.ts Normal file
View File

@ -0,0 +1,23 @@
import { Message } from 'eris';
import { Command } from '../class';
import { Client } from '..';
import SystemD_Linger from './systemd_linger';
export default class SystemD extends Command {
constructor(client: Client) {
super(client);
this.name = 'systemd';
this.description = 'Manages various aspects for your user SystemD.';
this.usage = `Run ${this.client.config.prefix}${this.name} [subcommand] for usage information`;
this.subcmds = [SystemD_Linger];
this.enabled = true;
}
public run(message: Message) {
try {
return this.client.commands.get('help').run(message, [this.name]);
} catch (error) {
return this.client.util.handleError(error, message, this);
}
}
}

View File

@ -0,0 +1,37 @@
/* eslint-disable consistent-return */
import { Message } from 'eris';
import { Command } from '../class';
import { Client } from '..';
export default class SystemdD_Linger extends Command {
constructor(client: Client) {
super(client);
this.name = 'linger';
this.description = 'Enables login linger for your user, this means your SystemD services will start on reboot.';
this.usage = `${this.client.config.prefix}systemd linger <enable | disable>`;
this.enabled = true;
}
public async run(message: Message, args: string[]) {
try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const account = await this.client.db.Account.findOne({ userID: message.author.id }).lean().exec();
if (!account) return this.error(message.channel, 'You do not have a Cloud Services account.');
switch (args[0]) {
case 'enable':
await this.client.util.exec(`loginctl enable-linger ${account.username}`);
this.success(message.channel, 'Successfully activated SystemdD linger.');
break;
case 'disable':
await this.client.util.exec(`loginctl disable-linger ${account.username}`);
this.success(message.channel, 'Successfully deactivated SystemD linger.');
break;
default:
this.error(message.channel, 'Invalid argument provided.');
break;
}
} catch (err) {
this.client.util.handleError(err, message, this);
}
}
}