-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart.js
More file actions
52 lines (48 loc) · 1.51 KB
/
Copy pathstart.js
File metadata and controls
52 lines (48 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/** @param {NS} ns **/
const CLUSTER_SCRIPTS = ["d_cluster.js", "d_discovery.js", "d_tasker.js", "d_scanner.js"];
const SMALL_SCRIPTS = ["d_small_scanner.js"];
function sum(a,b){ return a+b; }
export async function main(ns) {
const me = ns.getHostname();
const args = ns.flags([
["cluster", false],
["small", false],
["help", false]
]);
const clusterRamReq = CLUSTER_SCRIPTS.map((s) => { return ns.getScriptRam(s); }).reduce(sum, 0);
const smallRamReq = SMALL_SCRIPTS.map((s) => { return ns.getScriptRam(s); }).reduce(sum, 0);
function showHelp(){
ns.tprint(`
------------------------------
DSTACK'S BITBURNER KIT!
------------------------------
This script starts the automatic scan, root, and exploit system.
--cluster Attempts to start in cluster mode.
Requires ${clusterRamReq} RAM
--small Attempts to start in small mode (no clustering).
Requires ${smallRamReq} RAM.
If neither mode is selected, this script will chose automatically.
`);
}
if(args.help){
showHelp();
}
const auto = !args.cluster && !args.small;
const myRam = ns.getServerMaxRam(me) - ns.getServerUsedRam(me);
if(auto && myRam > clusterRamReq){
args.cluster = true;
}
else if(auto && myRam > smallRamReq) {
args.small = true;
}
else if(auto) {
ns.tprint("WOW! You ran this on a server that can't support anything! Good job, doofus.")
ns.exit();
}
if(args.cluster){
ns.run("d_cluster.js", 1);
}
else {
ns.run("d_small-scanner.js", 1);
}
}