From bc9146c219c70dd0c5e06905751f55ca48be8034 Mon Sep 17 00:00:00 2001 From: lub Date: Sun, 15 Oct 2017 18:29:24 +0200 Subject: [PATCH] create lubiland.js --- services/lubiland.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 services/lubiland.js diff --git a/services/lubiland.js b/services/lubiland.js new file mode 100644 index 0000000..0fd81d0 --- /dev/null +++ b/services/lubiland.js @@ -0,0 +1,22 @@ +const remoteExec = require('./remoteExec.js'); + +// links services and module.exports +const services = module.exports = {}; + +services['infrastructure'] = {}; + +services['infrastructure']['rebuild'] = {}; +services['infrastructure']['rebuild'].regex = /^([a-zA-Z0-9\-\_]*)$/; +services['infrastructure']['rebuild'].usage = ''; +services['infrastructure']['rebuild'].exec = (args) => { + const container = args[1]; + + matrixClient.sendNotice(room.roomId, 'rebuilding container ' + container); + + remoteExec('./rebuild.sh ' + container) + .then(function(result) { + matrixClient.sendNotice(room.roomId, event.sender.userId + '\nrebuilt container ' + container); + }, function(result) { + matrixClient.sendNotice(room.roomId, event.sender.userId + '\nrebuild of container ' + container + ' failed.\ncode: ' + result.code + '\nstdout: \n```\n' + result.stdout + '```\nstderr: \n```\n' + result.stderr + '\n```'); + }); +}; \ No newline at end of file