mirror of
https://github.com/linuxserver/core.git
synced 2026-02-20 05:07:19 +08:00
Using nc -z as portScanner fails in parallel. Moving gce script
This commit is contained in:
parent
a05b702de2
commit
40430bf58a
40
node_modules/c9/gce.js
generated
vendored
Normal file
40
node_modules/c9/gce.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
var childProcess = require("child_process");
|
||||
|
||||
|
||||
function findServers(pattern, options, callback) {
|
||||
if (!callback && typeof options == "function") {
|
||||
return findServers(pattern, {}, options);
|
||||
}
|
||||
|
||||
childProcess.exec("gssh --print-names " + pattern, function (err, stdout) {
|
||||
if (err) return callback(err);
|
||||
|
||||
var serverNames = stdout.split("\n")
|
||||
.filter(function(name) { return !!name; })
|
||||
.map(function (name) { return name.replace(/ubuntu@/, ""); });
|
||||
|
||||
return callback(null, serverNames);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function runCommand(pattern, command, options, callback) {
|
||||
if (!callback && typeof options == "function") {
|
||||
return runCommand(pattern, command, {}, options);
|
||||
}
|
||||
|
||||
var parallel = ""
|
||||
if (options.parallel) {
|
||||
parallel = " -P"
|
||||
}
|
||||
|
||||
var gsshCommand = "gssh " + parallel + " " + pattern + " '" + command + "'";
|
||||
childProcess.exec(gsshCommand, function (err, stdout) {
|
||||
return callback(err, stdout);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
find: findServers,
|
||||
run: runCommand
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user