hola-server 0.8.8 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/bash.js +25 -1
- package/package.json +1 -1
package/core/bash.js
CHANGED
|
@@ -19,6 +19,30 @@ const get_log_file = async () => {
|
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
21
|
const run_script = async (host, script, log_extra) => {
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
exec(`ssh ${host.auth} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p ${host.port} ${host.user}@${host.ip} /bin/bash <<'EOT'\n ${script} \nEOT\n`, { maxBuffer: 1024 * 150000 }, (error, stdout) => {
|
|
24
|
+
if (error) {
|
|
25
|
+
if (is_log_error()) {
|
|
26
|
+
log_error(LOG_BASH, "error running on host:" + host.name + " the script:" + script + ",error:" + error, log_extra);
|
|
27
|
+
}
|
|
28
|
+
resolve({ stdout: stdout, err: "error running the script:" + script + ",error:" + error });
|
|
29
|
+
} else {
|
|
30
|
+
if (is_log_debug()) {
|
|
31
|
+
log_debug(LOG_BASH, "executing on host:" + host.name + ", script:" + script + ",stdout:" + stdout, log_extra);
|
|
32
|
+
}
|
|
33
|
+
resolve({ stdout: stdout });
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Run script and get stdout and this use file redirect to avoid progress bar issue
|
|
41
|
+
* @param {host info,contains user,ip and password} host
|
|
42
|
+
* @param {commands to run} script
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
const run_script_extra = async (host, script, log_extra) => {
|
|
22
46
|
const log_file = await get_log_file();
|
|
23
47
|
|
|
24
48
|
return new Promise((resolve) => {
|
|
@@ -322,4 +346,4 @@ const stop_process = async (host, process_name, stop_cmd, using_full, log_extra)
|
|
|
322
346
|
return has_process;
|
|
323
347
|
}
|
|
324
348
|
|
|
325
|
-
module.exports = { stop_process, scp, scpr, run_script, run_script_file, run_simple_cmd, run_local_cmd, run_simple_local_cmd, get_info, get_system_attributes, read_key_value_line, read_obj_line };
|
|
349
|
+
module.exports = { stop_process, scp, scpr, run_script, run_script_extra, run_script_file, run_simple_cmd, run_local_cmd, run_simple_local_cmd, get_info, get_system_attributes, read_key_value_line, read_obj_line };
|