From f1fd16cba3e4ac86e5b5a6aa0839056d5da1151f Mon Sep 17 00:00:00 2001 From: osmarks Date: Tue, 14 Nov 2023 19:11:18 +0000 Subject: [PATCH] shortcut key, fix framebuffering mechanism, assistant memory Some people apparently don't have a RightCtrl key. As a low-effort workaround, I let them rebind those shortcuts. textutils.pagedPrint was broken by the mechanism for inserting framebuffers for overlays, because it was *too* software-transparent. i fixed it and it is less. PotatOS Assistant now remembers things across reboots unless its memory is wiped. --- manifest | 4 +- omnidisk.lua | 260 +++++++++++++++++++++++++++++++++++++++++++++ src/main.lua | 13 +++ src/potatobios.lua | 55 ++++++---- website/index.html | 2 +- 5 files changed, 312 insertions(+), 22 deletions(-) create mode 100644 omnidisk.lua diff --git a/manifest b/manifest index 8f342d2..e4b4f01 100644 --- a/manifest +++ b/manifest @@ -1,2 +1,2 @@ -{"build":444,"description":"add loading indicator","files":{"LICENSES":"f3549d84d66eb53dd4a421a4341d77d3d217c1b117d67e3be8f5211adcda0952","autorun.lua":"d1d5932a48c6382abee9c0b4cd08cb62c647c5eedb0ff4401a887c7e3aa79934","bin/5rot26.lua":"417891a232e325476f980d31d88edc486d526611a6350ce47fd29cca464ebf2c","bin/ccemux.lua":"239476f58835b86bbcac31ce8af3c3acd3d198a55ab9ada78c62fbf358625a98","bin/chronometer.lua":"db5363993a04382145aef7db2fbe262f0bf10697a589e1e2d2f9ce0f87430dd8","bin/factor.lua":"f8d223839e6b9f4e8c85f46e8182e7ede7ec41e6644f0188d1f315014c79a2c0","bin/grep.lua":"1509bc267867b933e528ab74cfbc2a15fa2df0ec7389df4f9033194ab9037865","bin/kristminer.lua":"7e7f9fe2a6493d584ad6926cda915e02c1c3d800dc209680898ce930d0bb0e6f","bin/livegps.lua":"c3d17d495cda01aa1261e4c4fcd43439b29af422671972117ec34f68e32c5bba","bin/loading.lua":"c85f7aa1765170325155b921c1fceeb62643f552f12d41b529a22af3a67f5a97","bin/potatoflight.lua":"2fbb0b6f8d78728d8cb0ec64af1bc598bd00cb55f202378e7acdb86bba71efd1","bin/potatoplex.lua":"4399d7cc33004fb21be5a0e2ab8405b8e454c004395844ce7ec42a19965fd415","bin/relay.lua":"261ae6c220b83506e3326e8f2b091d246baae458ff0d2ee87512be2c4e35a75d","bin/tryhaskell.lua":"07810d85145da65a3e434154c79d5a9d72f2dcbe59c8d6829040fb925df878ec","bin/workspace.lua":"acc8bb6f08b243378b68ab5f611e9a6cc8216b0713343dc93ddaa9101f07ffc5","potatobios.lua":"a702171b6bbf2782aa7b4c0058fb89614c1f9d9e94176b7cb8e624ba41c50f74","signing-key.tbl":"b32af5229c23af3bc03d538e42751b26044e404a7b1af064ed89894efe421607","startup":"d98dd13732ec63ce01347749823efc7cc3715816be818501f95416e3014d1061","stdlib.hvl":"a6fd2620068f47794a9bbeed77bee3fd4962f848e6dd7c75137b30cd5665272e","update-key.hex":"8d8afb7a45833bb7d68f929421ad60a211d4d73e0ee03b24dc0106ba1de2e1a0","xlib/00_cbor.lua":"8b1cc3588a5e31298d22e50b6752a4413f12f8113622962ed6555557448b408b","xlib/01_skynet.lua":"9cb565d639a0acd7c763c3e7422482532cd0bda0cdfcc720089ab4a87e551339","xlib/03_heavlisp.lua":"82cdabd5286058c0ea4f27956f8c1144e198769c8b8ce9e91b26c930d711f710"},"sizes":{"LICENSES":4725,"autorun.lua":103691,"bin/5rot26.lua":1661,"bin/ccemux.lua":1673,"bin/chronometer.lua":1152,"bin/factor.lua":4263,"bin/grep.lua":1196,"bin/kristminer.lua":5566,"bin/livegps.lua":980,"bin/loading.lua":7707,"bin/potatoflight.lua":3417,"bin/potatoplex.lua":6584,"bin/relay.lua":3075,"bin/tryhaskell.lua":1867,"bin/workspace.lua":42971,"potatobios.lua":51645,"signing-key.tbl":190,"startup":8438,"stdlib.hvl":851,"update-key.hex":44,"xlib/00_cbor.lua":15831,"xlib/01_skynet.lua":3286,"xlib/03_heavlisp.lua":15643},"timestamp":1699800585} -{"hash":"fe7328e5f31e9e8b01e9b6d0198214029f04ed59076ad2d6fdd20262d27990b0","sig":"1088470e626d2e1ddc5465a982a978670962ab0236297a28100c33e377f41bcedab6f62a73e230e0c33b"} \ No newline at end of file +{"build":460,"description":"PotatOS Assistant memory","files":{"LICENSES":"f3549d84d66eb53dd4a421a4341d77d3d217c1b117d67e3be8f5211adcda0952","autorun.lua":"1e38281f95497e7fbe95785b33913b7a189b1158e7a1b404fc1e5323031175f1","bin/5rot26.lua":"417891a232e325476f980d31d88edc486d526611a6350ce47fd29cca464ebf2c","bin/ccemux.lua":"239476f58835b86bbcac31ce8af3c3acd3d198a55ab9ada78c62fbf358625a98","bin/chronometer.lua":"db5363993a04382145aef7db2fbe262f0bf10697a589e1e2d2f9ce0f87430dd8","bin/factor.lua":"f8d223839e6b9f4e8c85f46e8182e7ede7ec41e6644f0188d1f315014c79a2c0","bin/grep.lua":"1509bc267867b933e528ab74cfbc2a15fa2df0ec7389df4f9033194ab9037865","bin/kristminer.lua":"7e7f9fe2a6493d584ad6926cda915e02c1c3d800dc209680898ce930d0bb0e6f","bin/livegps.lua":"c3d17d495cda01aa1261e4c4fcd43439b29af422671972117ec34f68e32c5bba","bin/loading.lua":"c85f7aa1765170325155b921c1fceeb62643f552f12d41b529a22af3a67f5a97","bin/potatoflight.lua":"2fbb0b6f8d78728d8cb0ec64af1bc598bd00cb55f202378e7acdb86bba71efd1","bin/potatoplex.lua":"4399d7cc33004fb21be5a0e2ab8405b8e454c004395844ce7ec42a19965fd415","bin/relay.lua":"261ae6c220b83506e3326e8f2b091d246baae458ff0d2ee87512be2c4e35a75d","bin/tryhaskell.lua":"07810d85145da65a3e434154c79d5a9d72f2dcbe59c8d6829040fb925df878ec","bin/workspace.lua":"acc8bb6f08b243378b68ab5f611e9a6cc8216b0713343dc93ddaa9101f07ffc5","potatobios.lua":"07a5ba0be0a278fbaf2c33f8cc08adff738e8903165aeb74bf3160ab8290e6a5","signing-key.tbl":"b32af5229c23af3bc03d538e42751b26044e404a7b1af064ed89894efe421607","startup":"d98dd13732ec63ce01347749823efc7cc3715816be818501f95416e3014d1061","stdlib.hvl":"a6fd2620068f47794a9bbeed77bee3fd4962f848e6dd7c75137b30cd5665272e","update-key.hex":"8d8afb7a45833bb7d68f929421ad60a211d4d73e0ee03b24dc0106ba1de2e1a0","xlib/00_cbor.lua":"8b1cc3588a5e31298d22e50b6752a4413f12f8113622962ed6555557448b408b","xlib/01_skynet.lua":"9cb565d639a0acd7c763c3e7422482532cd0bda0cdfcc720089ab4a87e551339","xlib/03_heavlisp.lua":"82cdabd5286058c0ea4f27956f8c1144e198769c8b8ce9e91b26c930d711f710"},"sizes":{"LICENSES":4725,"autorun.lua":104010,"bin/5rot26.lua":1661,"bin/ccemux.lua":1673,"bin/chronometer.lua":1152,"bin/factor.lua":4263,"bin/grep.lua":1196,"bin/kristminer.lua":5566,"bin/livegps.lua":980,"bin/loading.lua":7707,"bin/potatoflight.lua":3417,"bin/potatoplex.lua":6584,"bin/relay.lua":3075,"bin/tryhaskell.lua":1867,"bin/workspace.lua":42971,"potatobios.lua":52245,"signing-key.tbl":190,"startup":8438,"stdlib.hvl":851,"update-key.hex":44,"xlib/00_cbor.lua":15831,"xlib/01_skynet.lua":3286,"xlib/03_heavlisp.lua":15643},"timestamp":1699988880} +{"hash":"aa934a92d7e0dbeed14a4e23eed03d01d4fa4f8d80dbd418f5b346b1ea377d8a","sig":"7d34037f8a5aac6e5b14b54c02b1ea899036e82110baa7b94271767d6716f4fcdd3fb674918411e8871e"} \ No newline at end of file diff --git a/omnidisk.lua b/omnidisk.lua new file mode 100644 index 0000000..08190bd --- /dev/null +++ b/omnidisk.lua @@ -0,0 +1,260 @@ +--[[ +PotatOS OmniDisk +A new system to unify the existing PotatOS Uninstall/Debug/Update disks currently in existence. +Comes with a flexible, modular design, centralized licensing, possibly neater code, and a menu. + +This is designed to be executed by the OmniDisk Loader (https://pastebin.com/S1RS76pv) but may run on its own, though this is NOT a supported configuration. + +This is NOT usable simply by copying it onto a disk due to PotatOS signing requirements. +You must use the dcopy (https://pastebin.com/TfNgRUKC) program or manually generate a hex-format ECC signature and write it to "disk/signature" (PotatOS will, however, not run it unless this signature is from the PDSK). +]] + +local function try_report_incident(...) + if _G.report_incident then + _G.report_incident(...) + print "This incident has been reported." + end +end + +local r = process.get_running() +local sandbox = process.info "sandbox" +if sandbox then + for _, p in pairs(process.list()) do + if p.parent == sandbox and p.ID ~= r.ID then + process.signal(p.ID, process.signals.KILL) + end + end +end +pcall(process.signal, "sandbox", process.signals.KILL) +os.queueEvent "stop" + +local function fetch(URL) + local h, e = http.get(URL) + if not h then error(e) end + local o = h.readAll() + h.close() + return o +end + +local UUID = "@UUID@" -- Populated by dcopy utility, in some setups + +local args = ... + +if type(args) == "table" and args.UUID then UUID = args.UUID end + +local json +if _G.json_for_disks_and_such then json = _G.json_for_disks_and_such +elseif textutils.unserialiseJSON then + json = { encode = textutils.serialiseJSON, decode = textutils.unserialiseJSON } +else error "No JSON library exists, somehow" end +local license_data = fetch "https://pastebin.com/raw/viz0spjb" +local licenses = json.decode(license_data) +local license = licenses[UUID] + +local disk_ID +local disk_loader_args = args.arguments +if type(disk_loader_args) == "table" and disk_loader_args.ID then + disk_ID = disk_loader_args.ID +end + +local function runfile(program, ...) + local ok, err = loadfile(program) + if not ok then error(err) end + ok(...) +end + +local features = { + test = { + fn = function() print "Hello, World!" end, + description = "Test function." + }, + exit = { + fn = function() os.reboot() end, + description = "Leave OmniDisk, return to PotatOS.", + always_permitted = true + }, + UUID = { + fn = function() print("UUID:", UUID) print("Disk ID:", disk_ID or "[???]") end, + description = "Print this OmniDisk's Licensing UUID.", + always_permitted = true + }, + uninstall = { + fn = function() print "Uninstalling..." _G.uninstall "omnidisk" end, + description = "Uninstall potatOS" + }, + REPL = { + fn = function() runfile("/rom/programs/shell.lua", "lua") end, + description = "Open a Lua REPL for debugging." + }, + shell = { + fn = function() + printError "WARNING!" + print "Do not attempt to modify the code of this PotatOS OmniDisk. Unauthorized attempts to do so will invalidate the signature and make the disk unusable. All code beyond a limited core is stored in an online file to which you do not have write access. Probably. Contact gollark for further information." + runfile "/rom/programs/shell.lua" + end, + description = "Open an unsandboxed shell." + }, + update = { + fn = function() runfile("autorun", "update") end, + description = "Update PotatOS." + }, + dump_license = { + fn = function() print(UUID) textutils.pagedPrint(textutils.serialise(license)) end, + description = "Dump license information." + }, + primes = { + fn = function() + if not _G.findprime or not _G.isprime then + error "findprime/isprime not available. Update potatOS." + end + write "Difficulty? (1-16) " + local difficulty = tonumber(read()) + if type(difficulty) ~= "number" then error "ERR_PEBKAC\nThat's not a number." end + local maxrand = math.pow(10, difficulty) + local p1 = findprime(math.random(2, maxrand)) + local p2 = findprime(math.random(2, maxrand)) + + local num = p1 * p2 + print("Please find the prime factors of the following number:", num) + write "Factor 1: " + local f1 = tonumber(read()) + write "Factor 2: " + local f2 = tonumber(read()) + if (f1 == p1 and f2 == p2) or (f2 == p1 and f1 == p2) then + print "Yay! You got it right!" + else + print("Factors", f1, f2, "invalid.", p1, p2, "expected.") + end + end, + description = "Bored? You can factor some semiprimes!" + }, + potatoplex = { + fn = function() + write "Run potatoplex with arguments: " + local args = read() + runfile("rom/programs/http/pastebin.lua", "run", "wYBZjQhN", args) + end, + description = "Potatoplex your life!" + }, + chronometer = { + fn = function() + runfile("rom/programs/http/pastebin.lua", "run", "r24VMWk4") + end, + description = "Tell the time with Chronometer!" + }, + latest_paste = { + fn = function() + write "WARNING: This views the latest paste on Pastebin. Exposure to the raw output of the Internet may be detrimental to your mental health. Do you want to continue (y/n)? " + local yn = read() + if not yn:lower():match "y" then return end + local html = fetch "https://pastebin.com/LW9RFpmY" + local id = html:match [[