2022-02-04 17:17:13 -05:00
|
|
|
/**
|
|
|
|
* Automatically download all the scripts in the repository.
|
|
|
|
*/
|
2022-02-04 11:49:05 -05:00
|
|
|
export async function main(ns) {
|
2022-02-10 15:25:21 -05:00
|
|
|
async function download(file) {
|
|
|
|
await ns.wget(`${src}${file}`, `${dest}${file}`);
|
|
|
|
const speed = ~~((Math.random() * 200) + 100) / 10;
|
|
|
|
ns.tprint(`${file} ${file.length <= 10 ? '\t' : ''}\t [==================>] 100% \t (${speed} MB/s)`);
|
|
|
|
}
|
|
|
|
|
2022-02-10 12:10:26 -05:00
|
|
|
// Setup
|
2022-02-09 22:25:22 -05:00
|
|
|
const src = 'https://gitlab.zakscode.com/ztimson/BitBurner/-/raw/develop/scripts/';
|
2022-02-10 15:25:21 -05:00
|
|
|
const dest = '/scripts/';
|
2022-02-09 22:25:22 -05:00
|
|
|
const fileList = [
|
2022-02-10 12:28:51 -05:00
|
|
|
'lib/arg-parser.js',
|
2022-02-04 17:17:13 -05:00
|
|
|
'auto-pwn.js',
|
|
|
|
'bruteforce.js',
|
|
|
|
'crawler.js',
|
|
|
|
'miner.js',
|
2022-02-10 15:25:21 -05:00
|
|
|
'node-manager.js'
|
2022-02-04 11:49:05 -05:00
|
|
|
];
|
|
|
|
|
2022-02-10 15:25:21 -05:00
|
|
|
// Update self & restart
|
|
|
|
if(!ns.args.length) {
|
|
|
|
ns.tprint("Updating self:");
|
|
|
|
await ns.sleep(1000);
|
|
|
|
await download('update.js');
|
|
|
|
await ns.sleep(500);
|
|
|
|
ns.tprint('');
|
|
|
|
ns.tprint("Restarting...");
|
|
|
|
await ns.sleep(2000);
|
|
|
|
return ns.exec(`${dest}update.js`, ns.getHostname(), 1, 1);
|
|
|
|
}
|
|
|
|
|
2022-02-04 17:17:13 -05:00
|
|
|
// Download each file
|
2022-02-04 19:13:35 -05:00
|
|
|
ns.tprint("Downloading scripts:");
|
2022-02-10 13:55:16 -05:00
|
|
|
ns.tprint('');
|
2022-02-09 22:25:22 -05:00
|
|
|
for(const file of fileList) {
|
2022-02-04 18:48:08 -05:00
|
|
|
await ns.sleep(500);
|
2022-02-10 15:25:21 -05:00
|
|
|
await download(file);
|
2022-02-04 11:49:05 -05:00
|
|
|
}
|
2022-02-10 13:55:16 -05:00
|
|
|
ns.tprint('');
|
2022-02-10 12:28:51 -05:00
|
|
|
ns.tprint('✅ Done!');
|
2022-02-10 13:55:16 -05:00
|
|
|
ns.tprint('');
|
2022-02-04 11:49:05 -05:00
|
|
|
}
|