kOS-scripts/boot/default.ks

56 lines
1.4 KiB
Plaintext
Raw Normal View History

@LAZYGLOBAL OFF.
clearscreen.
clearguis().
clearvecdraws().
set TERMINAL:width to 50.
set TERMINAL:height to 30.
CORE:doaction("Open Terminal", true).
2018-07-19 14:42:03 +02:00
print "=================== BOOTING ===================".
wait until SHIP:loaded and SHIP:unpacked.
wait 0.001.
2018-07-19 14:42:03 +02:00
if HOMECONNECTION:isconnected {
update_scripts().
} else {
print "No connection to KSC: not updating scripts.".
}
print "============= BOOT SEQUENCE COMPLETE =============".
function update_scripts {
2019-02-07 21:56:34 +01:00
//
// Copy all .ks-files from the archive to the CPU's internal storage.
2019-02-07 21:56:34 +01:00
//
// Get lexicon of existing items (files/directories) and sizes on the internal storage
local existing is LEXICON().
for item in CORE:volume:files:values {
set existing[item:name] to item:size.
}
2019-02-07 21:56:34 +01:00
for item in volume("ARCHIVE"):files:values {
2019-02-07 21:56:34 +01:00
copy_file_if_necessary(item).
}
}
2019-02-07 21:56:34 +01:00
function copy_file_if_necessary {
parameter file.
if item:name[0] = "." // skip linux hidden dirs (e.g. .git)
return.
if item:isfile and item:extension <> "ks" // skip non-script items (e.g. README.md)
return.
if existing:haskey(item:name) and item:size = existing[item:name] // skip if local item is same size
return.
print "Copying " + item:name.
copypath(path(volume("ARCHIVE")):combine(item:name), CORE:volume).
if item:name = "boot"
reboot. // reboot CPU if boot/ directory was updated
}