55 lines
1.1 KiB
Lua
55 lines
1.1 KiB
Lua
local LOCAL_MANIFEST_PATH = "/trapos/manifest.json"
|
|
|
|
-- I think this should be moved in `programs`
|
|
-- then we will run this motd program from startup/boot.lua
|
|
|
|
local function readLocalManifest()
|
|
if not fs.exists(LOCAL_MANIFEST_PATH) then
|
|
return nil
|
|
end
|
|
local f = fs.open(LOCAL_MANIFEST_PATH, "r")
|
|
if not f then
|
|
return nil
|
|
end
|
|
local data = f.readAll()
|
|
f.close()
|
|
if not data or data == "" then
|
|
return nil
|
|
end
|
|
return textutils.unserializeJSON(data)
|
|
end
|
|
|
|
local manifest = readLocalManifest()
|
|
if not manifest then
|
|
return
|
|
end
|
|
|
|
local name = manifest.name or "TrapOS"
|
|
local version = manifest.version or "?"
|
|
local branch = manifest.branch or "master"
|
|
local isBeta = branch == "next"
|
|
|
|
local hasColor = term.isColor and term.isColor()
|
|
local previousColor
|
|
|
|
if hasColor then
|
|
previousColor = term.getTextColor()
|
|
if isBeta then
|
|
term.setTextColor(colors.orange)
|
|
else
|
|
term.setTextColor(colors.lime)
|
|
end
|
|
end
|
|
|
|
if isBeta then
|
|
print(name .. " v" .. version .. " [BETA]")
|
|
else
|
|
print(name .. " v" .. version)
|
|
end
|
|
|
|
if hasColor and previousColor then
|
|
term.setTextColor(previousColor)
|
|
end
|
|
|
|
print()
|