diff --git a/sys/apis/injector.lua b/sys/apis/injector.lua index 83f19aa..95df150 100644 --- a/sys/apis/injector.lua +++ b/sys/apis/injector.lua @@ -1,4 +1,4 @@ -local DEFAULT_UPATH = 'https://raw.githubusercontent.com/kepler155c/opus/develop-1.8/sys/apis' +local DEFAULT_UPATH = 'https://raw.githubusercontent.com/kepler155c/opus/' .. _ENV.BRANCH .. '/sys/apis' local PASTEBIN_URL = 'http://pastebin.com/raw' local GIT_URL = 'https://raw.githubusercontent.com' diff --git a/sys/apps/Overview.lua b/sys/apps/Overview.lua index 42b5481..b38b273 100644 --- a/sys/apps/Overview.lua +++ b/sys/apps/Overview.lua @@ -366,13 +366,15 @@ function page:eventHandler(event) elseif event.type == 'lua' then multishell.openTab({ - path = 'sys/apps/Lua.lua', + path ='sys/apps/shell', + args = { 'sys/apps/Lua.lua' }, focused = true, }) elseif event.type == 'files' then multishell.openTab({ - path = 'sys/apps/Files.lua', + path ='sys/apps/shell', + args = { 'sys/apps/Files.lua' }, focused = true, }) diff --git a/sys/apps/netdaemon.lua b/sys/apps/netdaemon.lua index 4195324..e0fd1d7 100644 --- a/sys/apps/netdaemon.lua +++ b/sys/apps/netdaemon.lua @@ -1,8 +1,6 @@ _G.requireInjector() -print('require event') local Event = require('event') -print('require util') local Util = require('util') local device = _G.device @@ -11,7 +9,6 @@ local network = _G.network local os = _G.os local printError = _G.printError -print('check wireless_modem') if not device.wireless_modem then return end diff --git a/sys/boot/opus.boot b/sys/boot/opus.boot index f24fe33..1adee42 100644 --- a/sys/boot/opus.boot +++ b/sys/boot/opus.boot @@ -24,15 +24,6 @@ term.redirect(kernelWindow) kernelWindow.parent = terminal local splashWindow -local function showStatus(status, ...) - local str = string.format(status, ...) - print(str) - splashWindow.setCursorPos(1, h) - splashWindow.clearLine() - splashWindow.setCursorPos((w - #str) / 2, h) - splashWindow.write(str) -end - local function splash() splashWindow = window.create(terminal, 1, 1, w, h, false) splashWindow.setTextColor(colors.white) @@ -57,6 +48,11 @@ local function splash() splashWindow.blit(string.rep(' ', #line), string.rep('a', #line), line) end end + + local str = 'Loading Opus OS...' + print(str) + splashWindow.setCursorPos((w - #str) / 2, h) + splashWindow.write(str) splashWindow.setVisible(true) return splashWindow end @@ -98,8 +94,6 @@ local args = { ... } splash() local s, m = pcall(function() - showStatus('Loading Opus OS...') - -- Install require shim if fs.exists('sys/apis/injector.lua') then _G.requireInjector = run('sys/apis/injector.lua') @@ -112,25 +106,28 @@ local s, m = pcall(function() fs.mount('', 'gitfs', GIT_REPO) end - --showStatus('Starting kernel') + -- runLevel 6 if passed a program to run + -- otherwise, runLevel 7 (multishell) run('sys/apps/shell', 'sys/kernel.lua', args[1] and 6 or 7) - if args[1] then - local s, m = _G.kernel.run({ - title = 'startup', - path = 'sys/apps/shell', - args = args, - haltOnExit = true, - }) - if s then - _G.kernel.raise(s.uid) - else - error(m) + kernel.hook('kernel_ready', function() + splashWindow.setVisible(false) + kernelWindow.setVisible(true) + if args[1] then + local s, m = _G.kernel.run({ + title = 'startup', + path = 'sys/apps/shell', + args = args, + haltOnExit = true, + }) + if s then + _G.kernel.raise(s.uid) + else + error(m) + end end - end - splashWindow.setVisible(false) - kernelWindow.setVisible(true) + end) _G.kernel.start() end) diff --git a/sys/extensions/7.multishell.lua b/sys/extensions/7.multishell.lua index 925ec26..94cd2e1 100644 --- a/sys/extensions/7.multishell.lua +++ b/sys/extensions/7.multishell.lua @@ -378,14 +378,16 @@ local function startup() end end -overviewId = multishell.openTab({ - path = 'sys/apps/Overview.lua', - isOverview = true, - focused = true, -}) -kernel.find(overviewId).title = '+' +kernel.hook('kernel_ready', function() + overviewId = multishell.openTab({ + path = 'sys/apps/Overview.lua', + isOverview = true, + focused = true, + }) + kernel.find(overviewId).title = '+' -multishell.openTab({ - fn = startup, - title = 'Autorun', -}) + multishell.openTab({ + fn = startup, + title = 'Autorun', + }) +end) diff --git a/sys/kernel.lua b/sys/kernel.lua index 9908ebb..d53a8c7 100644 --- a/sys/kernel.lua +++ b/sys/kernel.lua @@ -230,22 +230,26 @@ function kernel.start() term.redirect(kernel.terminal) end -local function loadExtensions(runLevel) +local function init(runLevel) + runLevel = tonumber(runLevel) or error('Invalid run level') + local dir = 'sys/extensions' local files = fs.list(dir) table.sort(files) for _,file in ipairs(files) do local level, name = file:match('(%d).(%S+).lua') ---print(name) if tonumber(level) <= runLevel then local s, m = shell.run(fs.combine(dir, file)) if not s then error(m) end - --os.sleep(0) end end + os.queueEvent('kernel_ready') end -local args = { ... } -loadExtensions(args[1] and tonumber(args[1]) or 7) +kernel.run({ + fn = init, + title = 'init', + args = { ... }, +}) diff --git a/sys/network/snmp.lua b/sys/network/snmp.lua index 1cefede..66f722e 100644 --- a/sys/network/snmp.lua +++ b/sys/network/snmp.lua @@ -3,11 +3,11 @@ local GPS = require('gps') local Socket = require('socket') local Util = require('util') -local device = _G.device -local multishell = _ENV.multishell -local network = _G.network -local os = _G.os -local turtle = _G.turtle +local device = _G.device +local kernel = _G.kernel +local network = _G.network +local os = _G.os +local turtle = _G.turtle -- move this into gps api local gpsRequested @@ -33,7 +33,7 @@ local function snmpConnection(socket) elseif msg.type == 'script' then local fn, err = loadstring(msg.args, 'script') if fn then - multishell.openTab({ + kernel.run({ fn = fn, title = 'script', })