2018-07-27 17:23:38 +02:00
|
|
|
@LAZYGLOBAL OFF.
|
|
|
|
|
2018-08-05 19:40:16 +02:00
|
|
|
clearscreen.
|
|
|
|
clearguis().
|
|
|
|
clearvecdraws().
|
|
|
|
|
2019-02-10 15:33:50 +01:00
|
|
|
set TERMINAL:width to max(TERMINAL:width, 50).
|
|
|
|
set TERMINAL:height to max(TERMINAL:height, 30).
|
2018-08-05 19:40:16 +02:00
|
|
|
CORE:doaction("Open Terminal", true).
|
|
|
|
|
2019-02-08 18:45:13 +01:00
|
|
|
print "==================== BOOTING =====================".
|
2018-08-05 19:40:16 +02:00
|
|
|
wait until SHIP:loaded and SHIP:unpacked.
|
2019-02-08 18:45:13 +01:00
|
|
|
wait 0.001. // wait one physics tick
|
2018-07-19 14:42:03 +02:00
|
|
|
|
2018-08-05 19:40:16 +02:00
|
|
|
if HOMECONNECTION:isconnected {
|
2019-02-08 03:49:57 +01:00
|
|
|
copy_scripts().
|
2018-07-26 04:06:14 +02:00
|
|
|
} else {
|
|
|
|
print "No connection to KSC: not updating scripts.".
|
|
|
|
}
|
|
|
|
|
2019-02-08 18:45:13 +01:00
|
|
|
print "============= BOOT SEQUENCE COMPLETE =============".
|
2018-07-26 04:06:14 +02:00
|
|
|
|
|
|
|
|
2019-02-08 03:49:57 +01:00
|
|
|
function copy_scripts {
|
2019-02-07 21:56:34 +01:00
|
|
|
//
|
2018-07-26 04:06:14 +02:00
|
|
|
// Copy all .ks-files from the archive to the CPU's internal storage.
|
2019-02-07 21:56:34 +01:00
|
|
|
//
|
2019-02-08 03:49:57 +01:00
|
|
|
parameter archive_dir is ARCHIVE:files.
|
|
|
|
|
|
|
|
for item in archive_dir:values {
|
|
|
|
function iteration { // allows for quick-bailing using 'return' (kOS doesn't have the 'continue' keyword
|
|
|
|
local item_path is "/" + path(item):segments:join("/"). // full path of item without volume id
|
|
|
|
if item:name[0] = "." // skip Linux hidden files and directories (e.g. .git)
|
|
|
|
return.
|
|
|
|
|
|
|
|
// Recurse on directories
|
|
|
|
if not item:isfile {
|
|
|
|
copy_scripts(item:list).
|
|
|
|
return.
|
|
|
|
}
|
|
|
|
|
|
|
|
if item:extension <> "ks" // skip non-script items (e.g. README.md)
|
|
|
|
return.
|
|
|
|
if CORE:volume:exists(item_path) and item:size = CORE:volume:open(item_path):size // skip if file exists locally with the same size
|
|
|
|
return.
|
|
|
|
|
|
|
|
print "Copying " + item_path.
|
|
|
|
copypath(item, path(CORE:volume):combine(item_path)).
|
|
|
|
if item_path = CORE:bootfilename {
|
|
|
|
print "Rebooting to apply new bootfile".
|
|
|
|
wait 2.
|
|
|
|
reboot.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iteration().
|
2018-07-26 04:06:14 +02:00
|
|
|
}
|
|
|
|
}
|