You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.6 KiB
JavaScript
43 lines
1.6 KiB
JavaScript
const remoteExec = require('../remoteExec.js');
|
|
|
|
// links lubiland and module.exports
|
|
const lubiland = module.exports = {};
|
|
|
|
lubiland['infrastructure'] = {};
|
|
|
|
lubiland['infrastructure']['rebuild'] = {};
|
|
lubiland['infrastructure']['rebuild'].regex = /^([a-zA-Z0-9\-\_]*)$/;
|
|
lubiland['infrastructure']['rebuild'].usage = '<container>';
|
|
lubiland['infrastructure']['rebuild'].exec = (args, room, event) => {
|
|
return new Promise((resolve, reject) => {
|
|
const container = args[1];
|
|
|
|
matrixClient.sendNotice(room.roomId, 'rebuilding container ' + container);
|
|
|
|
remoteExec('./rebuild.sh ' + container)
|
|
.then(function(success) {
|
|
matrixClient.sendNotice(room.roomId, event.sender.userId + '\nrebuilt container ' + container);
|
|
}, function(process) {
|
|
matrixClient.sendNotice(room.roomId, event.sender.userId + '\nrebuild of container ' + container + ' failed.\ncode: ' + process.code + '\nstdout: \n```\n' + process.stdout + '```\nstderr: \n```\n' + process.stderr + '\n```');
|
|
});
|
|
});
|
|
};
|
|
|
|
|
|
lubiland['heimdall'] = {};
|
|
|
|
lubiland['heimdall']['join'] = {};
|
|
lubiland['heimdall']['join'].regex = /^(.*)$/;
|
|
lubiland['heimdall']['join'].usage = '<container>';
|
|
lubiland['heimdall']['join'].exec = (args, room, event) => {
|
|
return new Promise((resolve, reject) => {
|
|
const roomId = args[1];
|
|
|
|
matrixClient.joinRoom(roomId)
|
|
.then((success) => {
|
|
matrixClient.sendNotice(room.roomId, ' joined ' + success.name);
|
|
}, (fail) => {
|
|
matrixClient.sendNotice(room.roomId, 'error while trying to join the other room: ' + fail.message);
|
|
})
|
|
});
|
|
}; |