kOS-scripts/boot/default.ks
Casper V. Kristensen 95c68aa15f
Improve auto-staging on launch to work with more ships.
Wait until ship fully loaded (unpacked) before commencing boot procedure.
2018-07-26 23:47:23 +02:00

41 lines
1.5 KiB
Plaintext
Executable file

CLEARSCREEN.
print "=================== BOOTING ===================".
wait until SHIP:UNPACKED.
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
}
}
}