diff --git a/scripts/ssl-manager.js b/scripts/ssl-manager.js index 44701e92..c1e82c7a 100644 --- a/scripts/ssl-manager.js +++ b/scripts/ssl-manager.js @@ -44,6 +44,7 @@ function SSLManager(config) { UPLOADER_ERROR = 12006, READ_TIMED_OUT = 12007, NO_VALID_IP_ADDRESSES = 12008, + ENVIRONMENT_NODE_GROUP_NOT_EXISTS = 2391, VALIDATION_SCRIPT = "validation.sh", SHELL_CODES = {}, INSTALL_LE_SCRIPT = "install-le.sh", @@ -362,7 +363,13 @@ function SSLManager(config) { }; me.uninstall = function () { - var autoUpdateScript = nodeManager.getScriptPath(AUTO_UPDATE_SCRIPT); + var autoUpdateScript = nodeManager.getScriptPath(AUTO_UPDATE_SCRIPT), + resp; + + resp = nodeManager.getEntryPointGroup(); + if (resp.result != 0) return resp; + + config.nodeGroup = resp.group; return me.execAll([ [ me.cmd, "crontab -l 2>/dev/null | grep -v '%(scriptPath)' | crontab -", { @@ -382,7 +389,8 @@ function SSLManager(config) { nodeManager.getScriptPath(INSTALL_LE_SCRIPT), nodeManager.getScriptPath(VALIDATION_SCRIPT), autoUpdateScript - ].join(DOMAINS_SEP) + ].join(DOMAINS_SEP), + nodeGroup: config.nodeGroup }] ]); }; @@ -710,10 +718,19 @@ function SSLManager(config) { propName, resp; + resp = me.cmd("[[ -f \"" + CUSTOM_CONFIG + "\" ]] && echo true || echo false", { nodeGroup: config.nodeGroup }); + + if (resp.result == ENVIRONMENT_NODE_GROUP_NOT_EXISTS) { + resp = nodeManager.getEntryPointGroup(); + if (resp.result != 0) return resp; + + config.nodeGroup = resp.group; + } + if (resp.result != 0) return resp; - if (resp.responses[0].out == "true") { + if (resp.responses && resp.responses[0] && resp.responses[0].out == "true") { resp = nodeManager.readFile(CUSTOM_CONFIG, config.nodeGroup); if (resp.result != 0) return resp;