Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / services / routing / server / applications / system.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x4ea2=['join','info','[%s][SYSTEM]\x20commnad:\x20%s','trim','replace','isEmpty','[%s][SYSTEM]\x20no\x20variable','body','isObject','next','validate','shelljs','lodash','./utils','../../../../config/logger','routing','string','command\x20is\x20a\x20string\x20and\x20it\x20is\x20required','consequence','length','error','[%s][SYSTEM]\x20%s','map','message'];(function(_0x34373d,_0x1c2910){var _0x3bd00c=function(_0x564722){while(--_0x564722){_0x34373d['push'](_0x34373d['shift']());}};_0x3bd00c(++_0x1c2910);}(_0x4ea2,0x15a));var _0x24ea=function(_0x3b3f4f,_0x403216){_0x3b3f4f=_0x3b3f4f-0x0;var _0x174dbe=_0x4ea2[_0x3b3f4f];return _0x174dbe;};'use strict';var schema=require(_0x24ea('0x0'));var sh=require(_0x24ea('0x1'));var _=require(_0x24ea('0x2'));var utils=require(_0x24ea('0x3'));var logger=require(_0x24ea('0x4'))(_0x24ea('0x5'));var system=schema({'command':{'type':_0x24ea('0x6'),'required':!![],'message':_0x24ea('0x7')}});exports[_0x24ea('0x8')]=function(_0x7314a6,_0x4c6e8c){return function(_0x3047ca){try{var _0x581387={'command':_0x4c6e8c[0x0]};var _0x734683=system[_0x24ea('0x0')](_0x581387,{'typecast':!![]});if(_0x734683[_0x24ea('0x9')]){logger[_0x24ea('0xa')](_0x24ea('0xb'),_0x7314a6,_[_0x24ea('0xc')](_0x734683,_0x24ea('0xd'))[_0x24ea('0xe')](',\x20'));logger[_0x24ea('0xf')]('[%s][SYSTEM]\x20no\x20command\x20executed,\x20force\x20next',_0x7314a6);_0x3047ca['next']();}else{var _0x3ba94e=this;var _0x27612f=utils['getMustacheRender'](_0x4c6e8c[0x0],this);logger[_0x24ea('0xf')](_0x24ea('0x10'),_0x7314a6,_0x27612f);sh['exec'](_[_0x24ea('0x11')](_0x27612f),function(_0x4b766b,_0x4d04c4){logger['info']('[%s][SYSTEM]\x20result\x20code:\x20%s',_0x7314a6,_0x4b766b);if(_0x4b766b==0x0){var _0x2f96af=_0x4d04c4[_0x24ea('0x12')](/(\r\n|\n|\r)/gm,'');if(_['isNil'](_0x4c6e8c[0x1])||_[_0x24ea('0x13')](_0x4c6e8c[0x1])){logger['info'](_0x24ea('0x14'),_0x7314a6);_0x3ba94e[_0x24ea('0x15')][_0x4c6e8c[0x1]]=_0x2f96af;}else{logger[_0x24ea('0xf')]('[%s][SYSTEM]\x20set\x20variable\x20%s:\x20%s',_0x7314a6,_0x4c6e8c[0x1],_0x2f96af);_0x3ba94e[_0x24ea('0x15')][_0x4c6e8c[0x1]]=_0x2f96af;}}_0x3047ca['next']();});}}catch(_0x17f339){logger[_0x24ea('0xa')](_0x24ea('0xb'),_0x7314a6,_[_0x24ea('0x16')](_0x17f339)?JSON['stringify'](_0x17f339):_0x17f339);logger[_0x24ea('0xf')]('[%s][SYSTEM]\x20no\x20command\x20executed,\x20force\x20next',_0x7314a6);_0x3047ca[_0x24ea('0x17')]();}};};