hola-server 0.8.2 → 0.8.4
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 +32 -7
- package/package.json +2 -2
package/core/bash.js
CHANGED
|
@@ -11,7 +11,7 @@ const LOG_BASH = "bash";
|
|
|
11
11
|
*/
|
|
12
12
|
const run_script = async (host, script) => {
|
|
13
13
|
return new Promise((resolve) => {
|
|
14
|
-
exec(`ssh
|
|
14
|
+
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) => {
|
|
15
15
|
if (error) {
|
|
16
16
|
if (is_log_error()) {
|
|
17
17
|
log_error(LOG_BASH, "error running on host:" + host.name + " the script:" + script + ",error:" + error);
|
|
@@ -29,7 +29,7 @@ const run_script = async (host, script) => {
|
|
|
29
29
|
|
|
30
30
|
const run_script_file = async (host, script_file) => {
|
|
31
31
|
return new Promise((resolve) => {
|
|
32
|
-
exec(`ssh
|
|
32
|
+
exec(`ssh ${host.auth} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p ${host.port} ${host.user}@${host.ip} /bin/bash < ${script_file}`, (error, stdout) => {
|
|
33
33
|
if (error) {
|
|
34
34
|
if (is_log_error()) {
|
|
35
35
|
log_error(LOG_BASH, "error running on host:" + host.name + " the script_file:" + script_file + ",error:" + error);
|
|
@@ -75,17 +75,42 @@ const run_local_cmd = async (cmd, log_extra) => {
|
|
|
75
75
|
* @param {local file path} locale_file
|
|
76
76
|
* @returns
|
|
77
77
|
*/
|
|
78
|
-
const scp = async (host, remote_file, local_file) => {
|
|
78
|
+
const scp = async (host, remote_file, local_file, extra) => {
|
|
79
79
|
return new Promise((resolve) => {
|
|
80
|
-
exec(`
|
|
80
|
+
exec(`sshpass -p '${host.pwd}' scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P ${host.port} -q ${host.user}@${host.ip}:${remote_file} ${local_file}`, (error, stdout) => {
|
|
81
81
|
if (error) {
|
|
82
82
|
if (is_log_error()) {
|
|
83
|
-
log_error(LOG_BASH, "error scp on host:" + host.name + " remote:" + remote_file + ",local:" + local_file + ",error:" + error);
|
|
83
|
+
log_error(LOG_BASH, "error scp on host:" + host.name + " remote:" + remote_file + ",local:" + local_file + ",error:" + error, extra);
|
|
84
84
|
}
|
|
85
85
|
resolve({ err: "error scp:" + remote_file + " to locale:" + local_file + ",err:" + error });
|
|
86
86
|
} else {
|
|
87
87
|
if (is_log_debug()) {
|
|
88
|
-
log_debug(LOG_BASH, "executing scp on host:" + host.name + ", remote:" + remote_file + ",local:" + local_file + ",stdout:" + stdout);
|
|
88
|
+
log_debug(LOG_BASH, "executing scp on host:" + host.name + ", remote:" + remote_file + ",local:" + local_file + ",stdout:" + stdout, extra);
|
|
89
|
+
}
|
|
90
|
+
resolve({ stdout: stdout });
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Scp local file to remote file
|
|
98
|
+
* @param {remote host} host
|
|
99
|
+
* @param {local file path} locale_file
|
|
100
|
+
* @param {remote file path} remote_file
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
const scpr = async (host, local_file, remote_file, extra) => {
|
|
104
|
+
return new Promise((resolve) => {
|
|
105
|
+
exec(`sshpass -p '${host.pwd}' scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P ${host.port} -q ${local_file} ${host.user}@${host.ip}:${remote_file}`, (error, stdout) => {
|
|
106
|
+
if (error) {
|
|
107
|
+
if (is_log_error()) {
|
|
108
|
+
log_error(LOG_BASH, "error scpr on host:" + host.name + " remote:" + remote_file + ",local:" + local_file + ",error:" + error, extra);
|
|
109
|
+
}
|
|
110
|
+
resolve({ err: "error scp:" + remote_file + " to locale:" + local_file + ",err:" + error });
|
|
111
|
+
} else {
|
|
112
|
+
if (is_log_debug()) {
|
|
113
|
+
log_debug(LOG_BASH, "executing scpr on host:" + host.name + ", remote:" + remote_file + ",local:" + local_file + ",stdout:" + stdout, extra);
|
|
89
114
|
}
|
|
90
115
|
resolve({ stdout: stdout });
|
|
91
116
|
}
|
|
@@ -280,4 +305,4 @@ const stop_process = async (host, process_name, stop_cmd, using_full) => {
|
|
|
280
305
|
return has_process;
|
|
281
306
|
}
|
|
282
307
|
|
|
283
|
-
module.exports = { stop_process, scp, 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 };
|
|
308
|
+
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hola-server",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "a meta programming framework used to build nodejs restful api",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
"url": "https://github.com/hery-node/hola-server/issues"
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://github.com/hery-node/hola-server#readme"
|
|
46
|
-
}
|
|
46
|
+
}
|