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

@ -23,6 +23,7 @@ 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 systemd } from './systemd';
export { default as tier } from './tier'; export { default as tier } from './tier';
export { default as unban } from './unban'; export { default as unban } from './unban';
export { default as unlock } from './unlock'; export { default as unlock } from './unlock';

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);
}
}
}