2019-06-28 17:50:02 +00:00
|
|
|
local Packages = require('opus.packages')
|
2019-03-27 19:21:31 +00:00
|
|
|
|
|
|
|
local colors = _G.colors
|
|
|
|
local fs = _G.fs
|
|
|
|
local keys = _G.keys
|
|
|
|
local multishell = _ENV.multishell
|
|
|
|
local os = _G.os
|
|
|
|
local shell = _ENV.shell
|
|
|
|
local term = _G.term
|
|
|
|
|
|
|
|
local success = true
|
|
|
|
|
|
|
|
local function runDir(directory)
|
2019-06-18 19:19:24 +00:00
|
|
|
if not fs.exists(directory) then
|
|
|
|
return true
|
|
|
|
end
|
2019-03-27 19:21:31 +00:00
|
|
|
|
2019-06-18 19:19:24 +00:00
|
|
|
local files = fs.list(directory)
|
|
|
|
table.sort(files)
|
2019-03-27 19:21:31 +00:00
|
|
|
|
2019-06-18 19:19:24 +00:00
|
|
|
for _,file in ipairs(files) do
|
|
|
|
os.sleep(0)
|
|
|
|
local result, err = shell.run(directory .. '/' .. file)
|
2019-03-27 19:21:31 +00:00
|
|
|
|
2019-06-18 19:19:24 +00:00
|
|
|
if result then
|
|
|
|
if term.isColor() then
|
|
|
|
term.setTextColor(colors.green)
|
|
|
|
end
|
|
|
|
term.write('[PASS] ')
|
|
|
|
term.setTextColor(colors.white)
|
|
|
|
term.write(fs.combine(directory, file))
|
|
|
|
print()
|
|
|
|
else
|
|
|
|
if term.isColor() then
|
|
|
|
term.setTextColor(colors.red)
|
|
|
|
end
|
|
|
|
term.write('[FAIL] ')
|
|
|
|
term.setTextColor(colors.white)
|
|
|
|
term.write(fs.combine(directory, file))
|
|
|
|
if err then
|
|
|
|
_G.printError('\n' .. err)
|
|
|
|
end
|
|
|
|
print()
|
|
|
|
success = false
|
|
|
|
end
|
|
|
|
end
|
2019-03-27 19:21:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
runDir('sys/autorun')
|
2019-10-31 04:49:30 +00:00
|
|
|
for _, package in pairs(Packages:installedSorted()) do
|
|
|
|
local packageDir = 'packages/' .. package.name .. '/autorun'
|
2019-06-18 19:19:24 +00:00
|
|
|
runDir(packageDir)
|
2019-03-27 19:21:31 +00:00
|
|
|
end
|
|
|
|
runDir('usr/autorun')
|
|
|
|
|
|
|
|
if not success then
|
2019-06-18 19:19:24 +00:00
|
|
|
if multishell then
|
|
|
|
multishell.setFocus(multishell.getCurrent())
|
|
|
|
end
|
|
|
|
_G.printError('A startup program has errored')
|
|
|
|
print('Press enter to continue')
|
2019-03-27 19:21:31 +00:00
|
|
|
|
2019-06-18 19:19:24 +00:00
|
|
|
while true do
|
|
|
|
local e, code = os.pullEventRaw('key')
|
|
|
|
if e == 'terminate' or e == 'key' and code == keys.enter then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2019-03-27 19:21:31 +00:00
|
|
|
end
|
|
|
|
|