kOS-scripts/boot/default.ks

51 lines
1.7 KiB
Plaintext
Executable file

@LAZYGLOBAL OFF.
clearscreen.
clearguis().
clearvecdraws().
set TERMINAL:width to 50.
set TERMINAL:height to 30.
CORE:doaction("Open Terminal", true).
print "=================== BOOTING ===================".
wait until SHIP:loaded and SHIP:unpacked.
wait 0.001.
if HOMECONNECTION:isconnected {
update_scripts().
} else {
print "No connection to KSC: not updating scripts.".
}
print "============= BOOT SEQUENCE COMPLETE =============".
function update_scripts {
// Copy all .ks-files from the archive to the CPU's internal storage.
// 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.
}
// Check if items from the archive match those in the internal storage
for item in volume("ARCHIVE"):files:values {
local skip is false. // kOS doesn't support the 'continue' keyword...
if not skip and item:name[0] = "." set skip to true. // skip linux hidden dirs (e.g. .git)
if not skip and item:isfile
and item:extension <> "ks" set skip to true. // skip non-script items (e.g. README.md)
if not skip and existing:haskey(item:name)
and item:size = existing[item:name] set skip to true. // skip if local item is same size
if not skip {
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
}
}
}