2017-09-26 02:49:44 +00:00
|
|
|
-- Loads the Opus environment regardless if the file system is local or not
|
2017-10-14 07:41:54 +00:00
|
|
|
local colors = _G.colors
|
|
|
|
local fs = _G.fs
|
|
|
|
local http = _G.http
|
|
|
|
local term = _G.term
|
2016-12-11 19:24:52 +00:00
|
|
|
|
2017-09-26 02:49:44 +00:00
|
|
|
local w, h = term.getSize()
|
|
|
|
term.setTextColor(colors.white)
|
2017-09-26 03:18:36 +00:00
|
|
|
if term.isColor() then
|
2017-10-06 07:07:24 +00:00
|
|
|
term.setBackgroundColor(colors.black)
|
2017-09-26 05:40:02 +00:00
|
|
|
term.clear()
|
|
|
|
local opus = {
|
2017-10-06 07:07:24 +00:00
|
|
|
'fffff00',
|
|
|
|
'ffff07000',
|
|
|
|
'ff00770b00 4444',
|
|
|
|
'ff077777444444444',
|
|
|
|
'f07777744444444444',
|
|
|
|
'f0000777444444444',
|
2017-09-26 05:40:02 +00:00
|
|
|
'070000111744444',
|
|
|
|
'777770000',
|
|
|
|
'7777000000',
|
|
|
|
'70700000000',
|
|
|
|
'077000000000',
|
|
|
|
}
|
|
|
|
for k,line in ipairs(opus) do
|
|
|
|
term.setCursorPos((w - 18) / 2, k + (h - #opus) / 2)
|
|
|
|
term.blit(string.rep(' ', #line), string.rep('a', #line), line)
|
|
|
|
end
|
2017-09-26 03:18:36 +00:00
|
|
|
end
|
2017-09-26 05:40:02 +00:00
|
|
|
|
2017-10-06 07:07:24 +00:00
|
|
|
term.setCursorPos((w - 18) / 2, h)
|
|
|
|
term.write('Loading Opus...')
|
2017-09-26 05:40:02 +00:00
|
|
|
term.setCursorPos(w, h)
|
2017-09-26 02:49:44 +00:00
|
|
|
|
2017-10-05 22:05:57 +00:00
|
|
|
local GIT_REPO = 'kepler155c/opus/develop'
|
2017-09-26 02:49:44 +00:00
|
|
|
local BASE = 'https://raw.githubusercontent.com/' .. GIT_REPO
|
|
|
|
|
2017-10-20 08:23:17 +00:00
|
|
|
local sandboxEnv = setmetatable({ }, { __index = _G })
|
|
|
|
for k,v in pairs(_ENV) do
|
|
|
|
sandboxEnv[k] = v
|
|
|
|
end
|
2018-01-10 21:46:37 +00:00
|
|
|
sandboxEnv.multishell = _ENV.multishell or { }
|
2017-10-20 08:23:17 +00:00
|
|
|
|
2017-09-26 02:49:44 +00:00
|
|
|
local function makeEnv()
|
2017-09-26 09:34:31 +00:00
|
|
|
local env = setmetatable({ }, { __index = _G })
|
2017-10-20 08:23:17 +00:00
|
|
|
for k,v in pairs(sandboxEnv) do
|
2017-10-14 07:41:54 +00:00
|
|
|
env[k] = v
|
2017-09-25 21:00:02 +00:00
|
|
|
end
|
2017-09-26 02:49:44 +00:00
|
|
|
return env
|
|
|
|
end
|
2016-12-11 19:24:52 +00:00
|
|
|
|
2017-09-26 02:49:44 +00:00
|
|
|
-- os.run doesn't provide return values :(
|
|
|
|
local function run(file, ...)
|
|
|
|
local s, m = loadfile(file, makeEnv())
|
2017-09-25 21:00:02 +00:00
|
|
|
if s then
|
2017-09-26 19:18:44 +00:00
|
|
|
return s(...)
|
2017-09-25 21:00:02 +00:00
|
|
|
end
|
2017-09-26 19:18:44 +00:00
|
|
|
error('Error loading ' .. file .. '\n' .. m)
|
2016-12-11 19:24:52 +00:00
|
|
|
end
|
|
|
|
|
2017-09-26 02:49:44 +00:00
|
|
|
local function runUrl(file, ...)
|
|
|
|
local url = BASE .. '/' .. file
|
|
|
|
|
2017-10-14 07:41:54 +00:00
|
|
|
local u = http.get(url)
|
|
|
|
if u then
|
|
|
|
local fn = load(u.readAll(), url, nil, makeEnv())
|
|
|
|
u.close()
|
2017-09-26 02:49:44 +00:00
|
|
|
if fn then
|
|
|
|
return fn(...)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
error('Failed to download ' .. url)
|
|
|
|
end
|
|
|
|
|
2017-09-27 19:42:40 +00:00
|
|
|
_G.debug = function() end
|
|
|
|
|
2017-09-26 09:34:31 +00:00
|
|
|
-- Install require shim
|
2017-09-26 02:49:44 +00:00
|
|
|
if fs.exists('sys/apis/injector.lua') then
|
|
|
|
_G.requireInjector = run('sys/apis/injector.lua')
|
|
|
|
else
|
|
|
|
-- not local, run the file system directly from git
|
|
|
|
_G.requireInjector = runUrl('/sys/apis/injector.lua')
|
|
|
|
runUrl('/sys/extensions/vfs.lua')
|
|
|
|
|
|
|
|
-- install file system
|
|
|
|
fs.mount('', 'gitfs', GIT_REPO)
|
|
|
|
end
|
|
|
|
|
2018-01-10 21:46:37 +00:00
|
|
|
run('sys/kernel.lua')
|
2017-05-20 22:27:26 +00:00
|
|
|
|
2017-09-26 02:49:44 +00:00
|
|
|
-- install user file systems
|
2017-09-25 21:00:02 +00:00
|
|
|
fs.loadTab('usr/etc/fstab')
|
|
|
|
|
|
|
|
local args = { ... }
|
2017-09-26 02:49:44 +00:00
|
|
|
if args[1] then
|
|
|
|
term.setBackgroundColor(colors.black)
|
|
|
|
term.clear()
|
|
|
|
term.setCursorPos(1, 1)
|
|
|
|
end
|
2017-09-25 21:10:24 +00:00
|
|
|
args[1] = args[1] or 'sys/apps/multishell'
|
|
|
|
run('sys/apps/shell', table.unpack(args))
|
2017-09-26 02:49:44 +00:00
|
|
|
|
|
|
|
fs.restore()
|