forked from engineering/cloudservices
add systemd status cmd
parent
51ba72ff08
commit
050335b760
|
@ -17,7 +17,7 @@ export default class Exec extends Command {
|
|||
try {
|
||||
if (!args.length) return this.client.commands.get('help').run(message, [this.name]);
|
||||
|
||||
const response = await this.loading(message.channel, `***Executing \`${args.join(' ')}\``);
|
||||
const response = await this.loading(message.channel, `***Executing \`${args.join(' ')}\`***`);
|
||||
let result: string;
|
||||
try {
|
||||
result = await this.client.util.exec(args.join(' '), { cwd: '/opt/CloudServices' });
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
import { Message } from 'eris';
|
||||
import { Client, Command, RichEmbed } from '../class';
|
||||
|
||||
export default class SystemD_Status extends Command {
|
||||
constructor(client: Client) {
|
||||
super(client);
|
||||
this.name = 'status';
|
||||
this.description = 'Prints out the status of a SystemD service that you run.';
|
||||
this.usage = `${this.client.config.prefix}systemd status <service name.`;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, ['systemd', 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.');
|
||||
const cmd = await this.client.util.exec(`runuser ${account.username} -c 'DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/\${UID}/bus" systemctl --user s
|
||||
tatus ${args[0]}'`);
|
||||
if (cmd.includes('could not be found')) return this.error(message.channel, 'The service name you provided doesn\'t exist.');
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle(`SystemD Status | ${args[0]}`);
|
||||
embed.setDescription(`\`\`\`sh\n${cmd}\n\`\`\``);
|
||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
||||
embed.setTimestamp();
|
||||
return message.channel.createMessage({ embed });
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue