Updated update script
This commit is contained in:
parent
e67bef2f76
commit
72ea910c8d
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
export async function downloadPrint(ns, file) {
|
export async function downloadPrint(ns, file) {
|
||||||
const speed = ~~(Math.random() * 100) / 10;
|
const speed = ~~(Math.random() * 100) / 10;
|
||||||
const spacing = Array(5 - Math.floor((file.length) / 8)).fill('\t').join('');
|
const spacing = Array(40 - file.length || 1).fill(' ').join('');
|
||||||
await slowPrint(ns, `${file}${spacing}[==================>] 100% \t (${speed} MB/s)`);
|
await slowPrint(ns, `${file}${spacing}[==================>] 100% \t (${speed} MB/s)`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,10 +121,11 @@ export async function main(ns) {
|
|||||||
ns.disableLog('ALL');
|
ns.disableLog('ALL');
|
||||||
const updateFile = 'update.js';
|
const updateFile = 'update.js';
|
||||||
const argParser = new ArgParser(updateFile, 'Download the latest script updates from the repository using wget.', null, [
|
const argParser = new ArgParser(updateFile, 'Download the latest script updates from the repository using wget.', null, [
|
||||||
{name: 'target', desc: 'Target device to update, defaults to current machine', optional: true, default: ns.getHostname(), type: 'string'}
|
{name: 'skip', desc: 'Skip updating self (for debugging)', optional: true, type: 'bool'},
|
||||||
|
{name: 'device', desc: 'Device to update, defaults to current machine', flags: ['-d', '--device'], default: ns.getHostname(), type: 'string'}
|
||||||
]);
|
]);
|
||||||
const src = 'https://gitlab.zakscode.com/ztimson/BitBurner/-/raw/develop/scripts/';
|
const src = 'https://gitlab.zakscode.com/ztimson/BitBurner/-/raw/develop/scripts/';
|
||||||
const dest = '/scripts2/';
|
const dest = '/scripts/';
|
||||||
const fileList = [
|
const fileList = [
|
||||||
'lib/arg-parser.js',
|
'lib/arg-parser.js',
|
||||||
'lib/utils.js',
|
'lib/utils.js',
|
||||||
@ -143,17 +144,23 @@ export async function main(ns) {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ns.args.length) { // Update self & restart
|
// Banner
|
||||||
|
ns.tprint('===================================================');
|
||||||
|
ns.tprint(`Updating: ${args['device']}`);
|
||||||
|
ns.tprint('===================================================');
|
||||||
|
|
||||||
|
// Run
|
||||||
|
if(!args['skip']) { // Update self & restart
|
||||||
await slowPrint(ns, 'Updating self:');
|
await slowPrint(ns, 'Updating self:');
|
||||||
await ns.wget(`${src}${updateFile}`, `${dest}${updateFile}`, args['target']);
|
await ns.wget(`${src}${updateFile}`, `${dest}${updateFile}`, args['target']);
|
||||||
await downloadPrint(ns, `${dest}${updateFile}`);
|
await downloadPrint(ns, `${dest}${updateFile}`);
|
||||||
ns.tprint('');
|
ns.tprint('');
|
||||||
await slowPrint(ns, 'Restarting...');
|
await slowPrint(ns, 'Restarting...');
|
||||||
|
ns.tprint('');
|
||||||
return ns.exec(`${dest}${updateFile}`, args['target'], 1, 1);
|
return ns.exec(`${dest}${updateFile}`, args['target'], 1, 1);
|
||||||
} else { // Update everything else
|
} else { // Update everything else
|
||||||
ns.tprint('');
|
|
||||||
await slowPrint(ns, 'Downloading scripts:');
|
await slowPrint(ns, 'Downloading scripts:');
|
||||||
for(let file in fileList) {
|
for(let file of fileList) {
|
||||||
await ns.wget(`${src}${file}`, `${dest}${file}`, args['target']);
|
await ns.wget(`${src}${file}`, `${dest}${file}`, args['target']);
|
||||||
await downloadPrint(ns, `${dest}${file}`);
|
await downloadPrint(ns, `${dest}${file}`);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user