mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
Meow?
This commit is contained in:
parent
8b04a3b4b3
commit
ae57b69278
659
EFI/Full.lua
Executable file → Normal file
659
EFI/Full.lua
Executable file → Normal file
@ -1,329 +1,330 @@
|
||||
|
||||
|
||||
-- local component, computer, unicode = require("component"), require("computer"), require("unicode")
|
||||
|
||||
local stringsMain, stringsBootFromURL, stringsChangeLabel, stringKeyDown, stringsInit, stringsFilesystem, componentProxy, componentList, pullSignal, uptime, tableInsert, mathMax, mathMin, mathHuge = "MineOS EFI", "Internet boot", "Change label", "key_down", "/init.lua", "filesystem", component.proxy, component.list, computer.pullSignal, computer.uptime, table.insert, math.max, math.min, math.huge
|
||||
local colorsTitle, colorsBackground, colorsText, colorsSelectionBackground, colorsSelectionText, eeprom, gpu, internetAddress = 1, 0, 1, 1, 0, componentProxy(componentList("eeprom")()), componentProxy(componentList("gpu")()), componentList("internet")()
|
||||
gpu.bind(componentList("screen")(), true)
|
||||
local shutdown, gpuSet, gpuFill, eepromSetData, eepromGetData, depth, screenWidth, screenHeight, curentBackground, currentForeground, NIL = computer.shutdown, gpu.set, gpu.fill, eeprom.setData, eeprom.getData, gpu.getDepth(), gpu.getResolution()
|
||||
|
||||
computer.getBootAddress, computer.setBootAddress = eepromGetData, eepromSetData
|
||||
|
||||
if depth == 4 then
|
||||
colorsTitle, colorsBackground, colorsText, colorsSelectionBackground, colorsSelectionText = 0x333333, 0xFFFFFF, 0x333333, 0x333333, 0xFFFFFF
|
||||
elseif depth == 8 then
|
||||
colorsTitle, colorsBackground, colorsText, colorsSelectionBackground, colorsSelectionText = 0x2D2D2D, 0xE1E1E1, 0x878787, 0x878787, 0xE1E1E1
|
||||
end
|
||||
|
||||
local setBackground, setForeground, round, restrict =
|
||||
function(color)
|
||||
if color ~= curentBackground then
|
||||
gpu.setBackground(color)
|
||||
curentBackground = color
|
||||
end
|
||||
end,
|
||||
function(color)
|
||||
if color ~= currentForeground then
|
||||
gpu.setForeground(color)
|
||||
currentForeground = color
|
||||
end
|
||||
end,
|
||||
function(n)
|
||||
return math.floor(n + 0.5)
|
||||
end,
|
||||
function(text, limit, skip)
|
||||
if #text < limit then
|
||||
text = text .. string.rep(" ", limit - #text)
|
||||
else
|
||||
text = text:sub(1, limit)
|
||||
end
|
||||
|
||||
return text .. (skip and "" or " ")
|
||||
end
|
||||
|
||||
local rectangle, centrizedText, menuElement =
|
||||
function(x, y, width, height, color)
|
||||
setBackground(color)
|
||||
gpuFill(x, y, width, height, " ")
|
||||
end,
|
||||
function(y, foreground, text)
|
||||
local x = round(screenWidth / 2 - #text / 2)
|
||||
setForeground(foreground)
|
||||
gpuSet(x, y, text)
|
||||
end,
|
||||
function(text, callback, breakLoop)
|
||||
return {
|
||||
s = text,
|
||||
c = callback,
|
||||
b = breakLoop
|
||||
}
|
||||
end
|
||||
|
||||
local function status(y, titleText, statusText, needWait)
|
||||
y = y or round(screenHeight / 2 - 1)
|
||||
|
||||
rectangle(1, 1, screenWidth, screenHeight, colorsBackground)
|
||||
centrizedText(y, colorsTitle, titleText)
|
||||
centrizedText(y + 2, colorsText, statusText or "")
|
||||
if needWait then
|
||||
repeat
|
||||
local event = pullSignal()
|
||||
until event == stringKeyDown or event == "touch"
|
||||
end
|
||||
|
||||
return y
|
||||
end
|
||||
|
||||
local loadInit, menuBack, menu, input, netboot =
|
||||
function(proxy)
|
||||
status(NIL, stringsMain, "Booting from " .. proxy.address)
|
||||
|
||||
local data, chunk, handle, success, reason = "", "", proxy.open(stringsInit, "r")
|
||||
while chunk do
|
||||
data, chunk = data .. chunk, proxy.read(handle, mathHuge)
|
||||
end
|
||||
proxy.close(handle)
|
||||
|
||||
success, reason = load(data)
|
||||
if success then
|
||||
success, reason = pcall(success)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
status(NIL, stringsMain, "Failed to run init file: " .. reason, 1)
|
||||
end,
|
||||
function()
|
||||
return menuElement("Back", NIL, 1)
|
||||
end,
|
||||
function(titleText, elements)
|
||||
local spacing, selectedElement, maxLength = 2, 1, 0
|
||||
for i = 1, #elements do
|
||||
maxLength = math.max(maxLength, #elements[i].s)
|
||||
end
|
||||
|
||||
while 1 do
|
||||
local y, x, eventData = status(round(screenHeight / 2 - (#elements + 2) / 2), titleText) + 2
|
||||
|
||||
for i = 1, #elements do
|
||||
x = round(screenWidth / 2 - #elements[i].s / 2)
|
||||
|
||||
if i == selectedElement then
|
||||
rectangle(round(screenWidth / 2 - maxLength / 2) - 2, y, maxLength + 4, 1, colorsSelectionBackground)
|
||||
setForeground(colorsSelectionText)
|
||||
gpuSet(x, y, elements[i].s)
|
||||
else
|
||||
setBackground(colorsBackground)
|
||||
setForeground(colorsText)
|
||||
gpuSet(x, y, elements[i].s)
|
||||
end
|
||||
|
||||
y = y + 1
|
||||
end
|
||||
|
||||
eventData = {pullSignal()}
|
||||
if eventData[1] == stringKeyDown then
|
||||
if eventData[4] == 200 and selectedElement > 1 then
|
||||
selectedElement = selectedElement - 1
|
||||
elseif eventData[4] == 208 and selectedElement < #elements then
|
||||
selectedElement = selectedElement + 1
|
||||
elseif eventData[4] == 28 then
|
||||
if elements[selectedElement].c then
|
||||
elements[selectedElement].c()
|
||||
end
|
||||
|
||||
if elements[selectedElement].b then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
function(y, prefix)
|
||||
local text, state, eblo, eventData, char = "", true
|
||||
while 1 do
|
||||
eblo = prefix .. text
|
||||
gpuFill(1, y, screenWidth, 1, " ")
|
||||
gpuSet(round(screenWidth / 2 - #eblo / 2), y, eblo .. (state and "█" or ""))
|
||||
|
||||
eventData = {pullSignal(0.5)}
|
||||
if eventData[1] == stringKeyDown then
|
||||
if eventData[4] == 28 then
|
||||
return text
|
||||
elseif eventData[4] == 14 then
|
||||
text = text:sub(1, -2)
|
||||
else
|
||||
char = unicode.char(eventData[3])
|
||||
if char:match("^[%w%d%p%s]+") then
|
||||
text = text .. char
|
||||
end
|
||||
end
|
||||
|
||||
state = true
|
||||
elseif eventData[1] == "clipboard" then
|
||||
text = text .. eventData[3]
|
||||
elseif not eventData[1] then
|
||||
state = not state
|
||||
end
|
||||
end
|
||||
end,
|
||||
function(url)
|
||||
local runReason, data, handle, result, reason =
|
||||
function(text)
|
||||
status(NIL, stringsBootFromURL, "Internet boot failed: " .. text, 1)
|
||||
end,
|
||||
"",
|
||||
componentProxy(internetAddress).request(url)
|
||||
|
||||
if handle then
|
||||
status(NIL, stringsBootFromURL, "Downloading script...")
|
||||
while 1 do
|
||||
result, reason = handle.read(mathHuge)
|
||||
if result then
|
||||
data = data .. result
|
||||
else
|
||||
handle:close()
|
||||
|
||||
if reason then
|
||||
runReason(reason)
|
||||
else
|
||||
result, reason = load(data)
|
||||
if result then
|
||||
eepromSetData("#" .. url)
|
||||
result, reason = pcall(result)
|
||||
if result then
|
||||
return
|
||||
else
|
||||
runReason(reason)
|
||||
end
|
||||
else
|
||||
runReason(reason)
|
||||
end
|
||||
end
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
runReason("invalid URL-address")
|
||||
end
|
||||
end
|
||||
|
||||
status(NIL, stringsMain, "Hold Alt to show boot options menu")
|
||||
|
||||
local deadline, eventData = uptime() + 1
|
||||
while uptime() < deadline do
|
||||
eventData = {pullSignal(deadline - uptime())}
|
||||
if eventData[1] == stringKeyDown and eventData[4] == 56 then
|
||||
local utilities = {
|
||||
menuElement("Disk management", function()
|
||||
local filesystems, bootAddress = {menuBack()}, eepromGetData()
|
||||
|
||||
for address in componentList(stringsFilesystem) do
|
||||
local proxy = componentProxy(address)
|
||||
local label, isReadOnly = proxy.getLabel() or "Unnamed", proxy.isReadOnly()
|
||||
|
||||
tableInsert(filesystems, 1,
|
||||
menuElement(
|
||||
(address == bootAddress and "> " or " ") ..
|
||||
restrict(label, 10) ..
|
||||
restrict(proxy.spaceTotal() > 1048576 and "HDD" or proxy.spaceTotal() > 65536 and "FDD" or "SYS", 3) ..
|
||||
restrict(isReadOnly and "R" or "R/W", 3) ..
|
||||
address:sub(1, 8) .. " " ..
|
||||
restrict(string.format("%.2f", proxy.spaceUsed() / proxy.spaceTotal() * 100) .. "%", 6, 1),
|
||||
|
||||
function()
|
||||
local filesystemOptions = {menuBack()}
|
||||
|
||||
if not isReadOnly then
|
||||
tableInsert(filesystemOptions, 1, menuElement(stringsChangeLabel, function()
|
||||
proxy.setLabel(input(status(NIL, stringsChangeLabel) + 2, "Enter new name: "))
|
||||
end, 1))
|
||||
|
||||
tableInsert(filesystemOptions, 2, menuElement("Format", function()
|
||||
status(NIL, stringsMain, "Formatting filesystem " .. address)
|
||||
for _, file in ipairs(proxy.list("/")) do
|
||||
proxy.remove(file)
|
||||
end
|
||||
status(NIL, stringsMain, "Formatting finished", 1)
|
||||
end, 1))
|
||||
end
|
||||
|
||||
if proxy.exists(stringsInit) then
|
||||
tableInsert(filesystemOptions, 1, menuElement("Set as startup", function()
|
||||
eepromSetData(address)
|
||||
end, 1))
|
||||
end
|
||||
|
||||
menu(label .. " (" .. address .. ")", filesystemOptions)
|
||||
end
|
||||
, 1)
|
||||
)
|
||||
end
|
||||
|
||||
menu("Select filesystem to show options", filesystems)
|
||||
end),
|
||||
|
||||
menuElement("Shutdown", function()
|
||||
shutdown()
|
||||
end),
|
||||
|
||||
menuBack()
|
||||
}
|
||||
|
||||
if internetAddress then
|
||||
tableInsert(utilities, 2, menuElement(stringsBootFromURL, function()
|
||||
netboot(input(status(NIL, stringsBootFromURL) + 2, "Enter URL: "))
|
||||
end))
|
||||
end
|
||||
|
||||
menu(stringsMain, utilities)
|
||||
end
|
||||
end
|
||||
|
||||
local data, proxy = eepromGetData()
|
||||
if data:sub(1, 1) == "#" then
|
||||
netboot(data:sub(2, -1))
|
||||
else
|
||||
proxy = componentProxy(data)
|
||||
if proxy then
|
||||
loadInit(proxy)
|
||||
else
|
||||
for address in componentList(stringsFilesystem) do
|
||||
proxy = componentProxy(address)
|
||||
if proxy.exists(stringsInit) then
|
||||
eepromSetData(address)
|
||||
loadInit(proxy)
|
||||
break
|
||||
else
|
||||
proxy = nil
|
||||
end
|
||||
end
|
||||
|
||||
if not proxy then
|
||||
status(NIL, stringsMain, "No bootable mediums found", 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shutdown()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- local component, computer, unicode = require("component"), require("computer"), require("unicode")
|
||||
|
||||
local stringsMain, stringsBootFromURL, stringsChangeLabel, stringKeyDown, stringsInit, stringsFilesystem, componentProxy, componentList, pullSignal, uptime, tableInsert, mathMax, mathMin, mathHuge = "MineOS EFI", "Internet boot", "Change label", "key_down", "/init.lua", "filesystem", component.proxy, component.list, computer.pullSignal, computer.uptime, table.insert, math.max, math.min, math.huge
|
||||
local colorsTitle, colorsBackground, colorsText, colorsSelectionBackground, colorsSelectionText, eeprom, gpu, internetAddress = 1, 0, 1, 1, 0, componentProxy(componentList("eeprom")()), componentProxy(componentList("gpu")()), componentList("internet")()
|
||||
|
||||
gpu.bind(componentList("screen")(), true)
|
||||
|
||||
local shutdown, gpuSet, gpuFill, eepromSetData, eepromGetData, depth, screenWidth, screenHeight, curentBackground, currentForeground, NIL = computer.shutdown, gpu.set, gpu.fill, eeprom.setData, eeprom.getData, gpu.getDepth(), gpu.getResolution()
|
||||
computer.getBootAddress, computer.setBootAddress = eepromGetData, eepromSetData
|
||||
|
||||
if depth == 4 then
|
||||
colorsTitle, colorsBackground, colorsText, colorsSelectionBackground, colorsSelectionText = 0x333333, 0xFFFFFF, 0x333333, 0x333333, 0xFFFFFF
|
||||
elseif depth == 8 then
|
||||
colorsTitle, colorsBackground, colorsText, colorsSelectionBackground, colorsSelectionText = 0x2D2D2D, 0xE1E1E1, 0x878787, 0x878787, 0xE1E1E1
|
||||
end
|
||||
|
||||
local setBackground, setForeground, round, restrict =
|
||||
function(color)
|
||||
if color ~= curentBackground then
|
||||
gpu.setBackground(color)
|
||||
curentBackground = color
|
||||
end
|
||||
end,
|
||||
function(color)
|
||||
if color ~= currentForeground then
|
||||
gpu.setForeground(color)
|
||||
currentForeground = color
|
||||
end
|
||||
end,
|
||||
function(n)
|
||||
return math.floor(n + 0.5)
|
||||
end,
|
||||
function(text, limit, skip)
|
||||
if #text < limit then
|
||||
text = text .. string.rep(" ", limit - #text)
|
||||
else
|
||||
text = text:sub(1, limit)
|
||||
end
|
||||
|
||||
return text .. (skip and "" or " ")
|
||||
end
|
||||
|
||||
local rectangle, centrizedText, menuElement =
|
||||
function(x, y, width, height, color)
|
||||
setBackground(color)
|
||||
gpuFill(x, y, width, height, " ")
|
||||
end,
|
||||
function(y, foreground, text)
|
||||
local x = round(screenWidth / 2 - #text / 2)
|
||||
setForeground(foreground)
|
||||
gpuSet(x, y, text)
|
||||
end,
|
||||
function(text, callback, breakLoop)
|
||||
return {
|
||||
s = text,
|
||||
c = callback,
|
||||
b = breakLoop
|
||||
}
|
||||
end
|
||||
|
||||
local function status(y, titleText, statusText, needWait)
|
||||
y = y or round(screenHeight / 2 - 1)
|
||||
|
||||
rectangle(1, 1, screenWidth, screenHeight, colorsBackground)
|
||||
centrizedText(y, colorsTitle, titleText)
|
||||
centrizedText(y + 2, colorsText, statusText or "")
|
||||
if needWait then
|
||||
repeat
|
||||
local event = pullSignal()
|
||||
until event == stringKeyDown or event == "touch"
|
||||
end
|
||||
|
||||
return y
|
||||
end
|
||||
|
||||
local loadInit, menuBack, menu, input, netboot =
|
||||
function(proxy)
|
||||
status(NIL, stringsMain, "Booting from " .. proxy.address)
|
||||
|
||||
local data, chunk, handle, success, reason = "", "", proxy.open(stringsInit, "r")
|
||||
while chunk do
|
||||
data, chunk = data .. chunk, proxy.read(handle, mathHuge)
|
||||
end
|
||||
proxy.close(handle)
|
||||
|
||||
success, reason = load(data)
|
||||
if success then
|
||||
success, reason = pcall(success)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
status(NIL, stringsMain, "Failed to run init file: " .. reason, 1)
|
||||
end,
|
||||
function()
|
||||
return menuElement("Back", NIL, 1)
|
||||
end,
|
||||
function(titleText, elements)
|
||||
local spacing, selectedElement, maxLength = 2, 1, 0
|
||||
for i = 1, #elements do
|
||||
maxLength = math.max(maxLength, #elements[i].s)
|
||||
end
|
||||
|
||||
while 1 do
|
||||
local y, x, eventData = status(round(screenHeight / 2 - (#elements + 2) / 2), titleText) + 2
|
||||
|
||||
for i = 1, #elements do
|
||||
x = round(screenWidth / 2 - #elements[i].s / 2)
|
||||
|
||||
if i == selectedElement then
|
||||
rectangle(round(screenWidth / 2 - maxLength / 2) - 2, y, maxLength + 4, 1, colorsSelectionBackground)
|
||||
setForeground(colorsSelectionText)
|
||||
gpuSet(x, y, elements[i].s)
|
||||
else
|
||||
setBackground(colorsBackground)
|
||||
setForeground(colorsText)
|
||||
gpuSet(x, y, elements[i].s)
|
||||
end
|
||||
|
||||
y = y + 1
|
||||
end
|
||||
|
||||
eventData = {pullSignal()}
|
||||
if eventData[1] == stringKeyDown then
|
||||
if eventData[4] == 200 and selectedElement > 1 then
|
||||
selectedElement = selectedElement - 1
|
||||
elseif eventData[4] == 208 and selectedElement < #elements then
|
||||
selectedElement = selectedElement + 1
|
||||
elseif eventData[4] == 28 then
|
||||
if elements[selectedElement].c then
|
||||
elements[selectedElement].c()
|
||||
end
|
||||
|
||||
if elements[selectedElement].b then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
function(y, prefix)
|
||||
local text, state, eblo, eventData, char = "", true
|
||||
while 1 do
|
||||
eblo = prefix .. text
|
||||
gpuFill(1, y, screenWidth, 1, " ")
|
||||
gpuSet(round(screenWidth / 2 - #eblo / 2), y, eblo .. (state and "█" or ""))
|
||||
|
||||
eventData = {pullSignal(0.5)}
|
||||
if eventData[1] == stringKeyDown then
|
||||
if eventData[4] == 28 then
|
||||
return text
|
||||
elseif eventData[4] == 14 then
|
||||
text = text:sub(1, -2)
|
||||
else
|
||||
char = unicode.char(eventData[3])
|
||||
if char:match("^[%w%d%p%s]+") then
|
||||
text = text .. char
|
||||
end
|
||||
end
|
||||
|
||||
state = true
|
||||
elseif eventData[1] == "clipboard" then
|
||||
text = text .. eventData[3]
|
||||
elseif not eventData[1] then
|
||||
state = not state
|
||||
end
|
||||
end
|
||||
end,
|
||||
function(url)
|
||||
local runReason, data, handle, result, reason =
|
||||
function(text)
|
||||
status(NIL, stringsBootFromURL, "Internet boot failed: " .. text, 1)
|
||||
end,
|
||||
"",
|
||||
componentProxy(internetAddress).request(url)
|
||||
|
||||
if handle then
|
||||
status(NIL, stringsBootFromURL, "Downloading script...")
|
||||
while 1 do
|
||||
result, reason = handle.read(mathHuge)
|
||||
if result then
|
||||
data = data .. result
|
||||
else
|
||||
handle:close()
|
||||
|
||||
if reason then
|
||||
runReason(reason)
|
||||
else
|
||||
result, reason = load(data)
|
||||
if result then
|
||||
eepromSetData("#" .. url)
|
||||
result, reason = pcall(result)
|
||||
if result then
|
||||
return
|
||||
else
|
||||
runReason(reason)
|
||||
end
|
||||
else
|
||||
runReason(reason)
|
||||
end
|
||||
end
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
runReason("invalid URL-address")
|
||||
end
|
||||
end
|
||||
|
||||
status(NIL, stringsMain, "Hold Alt to show boot options menu")
|
||||
|
||||
local deadline, eventData = uptime() + 1
|
||||
while uptime() < deadline do
|
||||
eventData = {pullSignal(deadline - uptime())}
|
||||
if eventData[1] == stringKeyDown and eventData[4] == 56 then
|
||||
local utilities = {
|
||||
menuElement("Disk management", function()
|
||||
local filesystems, bootAddress = {menuBack()}, eepromGetData()
|
||||
|
||||
for address in componentList(stringsFilesystem) do
|
||||
local proxy = componentProxy(address)
|
||||
local label, isReadOnly = proxy.getLabel() or "Unnamed", proxy.isReadOnly()
|
||||
|
||||
tableInsert(filesystems, 1,
|
||||
menuElement(
|
||||
(address == bootAddress and "> " or " ") ..
|
||||
restrict(label, 10) ..
|
||||
restrict(proxy.spaceTotal() > 1048576 and "HDD" or proxy.spaceTotal() > 65536 and "FDD" or "SYS", 3) ..
|
||||
restrict(isReadOnly and "R" or "R/W", 3) ..
|
||||
address:sub(1, 8) .. " " ..
|
||||
restrict(string.format("%.2f", proxy.spaceUsed() / proxy.spaceTotal() * 100) .. "%", 6, 1),
|
||||
|
||||
function()
|
||||
local filesystemOptions = {menuBack()}
|
||||
|
||||
if not isReadOnly then
|
||||
tableInsert(filesystemOptions, 1, menuElement(stringsChangeLabel, function()
|
||||
proxy.setLabel(input(status(NIL, stringsChangeLabel) + 2, "Enter new name: "))
|
||||
end, 1))
|
||||
|
||||
tableInsert(filesystemOptions, 2, menuElement("Format", function()
|
||||
status(NIL, stringsMain, "Formatting filesystem " .. address)
|
||||
for _, file in ipairs(proxy.list("/")) do
|
||||
proxy.remove(file)
|
||||
end
|
||||
status(NIL, stringsMain, "Formatting finished", 1)
|
||||
end, 1))
|
||||
end
|
||||
|
||||
if proxy.exists(stringsInit) then
|
||||
tableInsert(filesystemOptions, 1, menuElement("Set as startup", function()
|
||||
eepromSetData(address)
|
||||
end, 1))
|
||||
end
|
||||
|
||||
menu(label .. " (" .. address .. ")", filesystemOptions)
|
||||
end
|
||||
, 1)
|
||||
)
|
||||
end
|
||||
|
||||
menu("Select filesystem to show options", filesystems)
|
||||
end),
|
||||
|
||||
menuElement("Shutdown", function()
|
||||
shutdown()
|
||||
end),
|
||||
|
||||
menuBack()
|
||||
}
|
||||
|
||||
if internetAddress then
|
||||
tableInsert(utilities, 2, menuElement(stringsBootFromURL, function()
|
||||
netboot(input(status(NIL, stringsBootFromURL) + 2, "Enter URL: "))
|
||||
end))
|
||||
end
|
||||
|
||||
menu(stringsMain, utilities)
|
||||
end
|
||||
end
|
||||
|
||||
local data, proxy = eepromGetData()
|
||||
if data:sub(1, 1) == "#" then
|
||||
netboot(data:sub(2, -1))
|
||||
else
|
||||
proxy = componentProxy(data)
|
||||
if proxy and proxy.exists(stringsInit) then
|
||||
loadInit(proxy)
|
||||
else
|
||||
for address in componentList(stringsFilesystem) do
|
||||
proxy = componentProxy(address)
|
||||
if proxy.exists(stringsInit) then
|
||||
eepromSetData(address)
|
||||
loadInit(proxy)
|
||||
break
|
||||
else
|
||||
proxy = nil
|
||||
end
|
||||
end
|
||||
|
||||
if not proxy then
|
||||
status(NIL, stringsMain, "No bootable mediums found", 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shutdown()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2
EFI/Minified.lua
Executable file → Normal file
2
EFI/Minified.lua
Executable file → Normal file
@ -1 +1 @@
|
||||
local a,b,c,d,e,f,g,h,i,j,k,l,m,n="MineOS EFI","Internet boot","Change label","key_down","/init.lua","filesystem",component.proxy,component.list,computer.pullSignal,computer.uptime,table.insert,math.max,math.min,math.huge;local o,p,q,r,s,t,u,v=1,0,1,1,0,g(h("eeprom")()),g(h("gpu")()),h("internet")()u.bind(h("screen")(),true)local w,x,y,z,A,B,C,D,E,F,G=computer.shutdown,u.set,u.fill,t.setData,t.getData,u.getDepth(),u.getResolution()computer.getBootAddress,computer.setBootAddress=A,z;if B==4 then o,p,q,r,s=0x333333,0xFFFFFF,0x333333,0x333333,0xFFFFFF elseif B==8 then o,p,q,r,s=0x2D2D2D,0xE1E1E1,0x878787,0x878787,0xE1E1E1 end;local H,I,J,K=function(L)if L~=E then u.setBackground(L)E=L end end,function(L)if L~=F then u.setForeground(L)F=L end end,function(M)return math.floor(M+0.5)end,function(N,O,P)if#N<O then N=N..string.rep(" ",O-#N)else N=N:sub(1,O)end;return N..(P and""or" ")end;local Q,R,S=function(T,U,V,W,L)H(L)y(T,U,V,W," ")end,function(U,X,N)local T=J(C/2-#N/2)I(X)x(T,U,N)end,function(N,Y,Z)return{s=N,c=Y,b=Z}end;local function _(U,a0,a1,a2)U=U or J(D/2-1)Q(1,1,C,D,p)R(U,o,a0)R(U+2,q,a1 or"")if a2 then repeat local a3=i()until a3==d or a3=="touch"end;return U end;local a4,a5,a6,a7,a8=function(a9)_(G,a,"Booting from "..a9.address)local aa,ab,ac,ad,ae="","",a9.open(e,"r")while ab do aa,ab=aa..ab,a9.read(ac,n)end;a9.close(ac)ad,ae=load(aa)if ad then ad,ae=pcall(ad)if ad then return end end;_(G,a,"Failed to run init file: "..ae,1)end,function()return S("Back",G,1)end,function(a0,af)local ag,ah,ai=2,1,0;for aj=1,#af do ai=math.max(ai,#af[aj].s)end;while 1 do local U,T,ak=_(J(D/2-(#af+2)/2),a0)+2;for aj=1,#af do T=J(C/2-#af[aj].s/2)if aj==ah then Q(J(C/2-ai/2)-2,U,ai+4,1,r)I(s)x(T,U,af[aj].s)else H(p)I(q)x(T,U,af[aj].s)end;U=U+1 end;ak={i()}if ak[1]==d then if ak[4]==200 and ah>1 then ah=ah-1 elseif ak[4]==208 and ah<#af then ah=ah+1 elseif ak[4]==28 then if af[ah].c then af[ah].c()end;if af[ah].b then return end end end end end,function(U,al)local N,am,an,ak,ao="",true;while 1 do an=al..N;y(1,U,C,1," ")x(J(C/2-#an/2),U,an..(am and"█"or""))ak={i(0.5)}if ak[1]==d then if ak[4]==28 then return N elseif ak[4]==14 then N=N:sub(1,-2)else ao=unicode.char(ak[3])if ao:match("^[%w%d%p%s]+")then N=N..ao end end;am=true elseif ak[1]=="clipboard"then N=N..ak[3]elseif not ak[1]then am=not am end end end,function(ap)local aq,aa,ac,ar,ae=function(N)_(G,b,"Internet boot failed: "..N,1)end,"",g(v).request(ap)if ac then _(G,b,"Downloading script...")while 1 do ar,ae=ac.read(n)if ar then aa=aa..ar else ac:close()if ae then aq(ae)else ar,ae=load(aa)if ar then z("#"..ap)ar,ae=pcall(ar)if ar then return else aq(ae)end else aq(ae)end end;break end end else aq("invalid URL-address")end end;_(G,a,"Hold Alt to show boot options menu")local as,ak=j()+1;while j()<as do ak={i(as-j())}if ak[1]==d and ak[4]==56 then local at={S("Disk management",function()local au,av={a5()},A()for aw in h(f)do local a9=g(aw)local ax,ay=a9.getLabel()or"Unnamed",a9.isReadOnly()k(au,1,S((aw==av and"> "or" ")..K(ax,10)..K(a9.spaceTotal()>1048576 and"HDD"or a9.spaceTotal()>65536 and"FDD"or"SYS",3)..K(ay and"R"or"R/W",3)..aw:sub(1,8).." "..K(string.format("%.2f",a9.spaceUsed()/a9.spaceTotal()*100).."%",6,1),function()local az={a5()}if not ay then k(az,1,S(c,function()a9.setLabel(a7(_(G,c)+2,"Enter new name: "))end,1))k(az,2,S("Format",function()_(G,a,"Formatting filesystem "..aw)for aA,aB in ipairs(a9.list("/"))do a9.remove(aB)end;_(G,a,"Formatting finished",1)end,1))end;if a9.exists(e)then k(az,1,S("Set as startup",function()z(aw)end,1))end;a6(ax.." ("..aw..")",az)end,1))end;a6("Select filesystem to show options",au)end),S("Shutdown",function()w()end),a5()}if v then k(at,2,S(b,function()a8(a7(_(G,b)+2,"Enter URL: "))end))end;a6(a,at)end end;local aa,a9=A()if aa:sub(1,1)=="#"then a8(aa:sub(2,-1))else a9=g(aa)if a9 then a4(a9)else for aw in h(f)do a9=g(aw)if a9.exists(e)then z(aw)a4(a9)break else a9=nil end end;if not a9 then _(G,a,"No bootable mediums found",1)end end end;w()
|
||||
local a,b,c,d,e,f,g,h,i,j,k,l,m,n="MineOS EFI","Internet boot","Change label","key_down","/init.lua","filesystem",component.proxy,component.list,computer.pullSignal,computer.uptime,table.insert,math.max,math.min,math.huge;local o,p,q,r,s,t,u,v=1,0,1,1,0,g(h("eeprom")()),g(h("gpu")()),h("internet")()u.bind(h("screen")(),true)local w,x,y,z,A,B,C,D,E,F,G=computer.shutdown,u.set,u.fill,t.setData,t.getData,u.getDepth(),u.getResolution()computer.getBootAddress,computer.setBootAddress=A,z;if B==4 then o,p,q,r,s=0x333333,0xFFFFFF,0x333333,0x333333,0xFFFFFF elseif B==8 then o,p,q,r,s=0x2D2D2D,0xE1E1E1,0x878787,0x878787,0xE1E1E1 end;local H,I,J,K=function(L)if L~=E then u.setBackground(L)E=L end end,function(L)if L~=F then u.setForeground(L)F=L end end,function(M)return math.floor(M+0.5)end,function(N,O,P)if#N<O then N=N..string.rep(" ",O-#N)else N=N:sub(1,O)end;return N..(P and""or" ")end;local Q,R,S=function(T,U,V,W,L)H(L)y(T,U,V,W," ")end,function(U,X,N)local T=J(C/2-#N/2)I(X)x(T,U,N)end,function(N,Y,Z)return{s=N,c=Y,b=Z}end;local function _(U,a0,a1,a2)U=U or J(D/2-1)Q(1,1,C,D,p)R(U,o,a0)R(U+2,q,a1 or"")if a2 then repeat local a3=i()until a3==d or a3=="touch"end;return U end;local a4,a5,a6,a7,a8=function(a9)_(G,a,"Booting from "..a9.address)local aa,ab,ac,ad,ae="","",a9.open(e,"r")while ab do aa,ab=aa..ab,a9.read(ac,n)end;a9.close(ac)ad,ae=load(aa)if ad then ad,ae=pcall(ad)if ad then return end end;_(G,a,"Failed to run init file: "..ae,1)end,function()return S("Back",G,1)end,function(a0,af)local ag,ah,ai=2,1,0;for aj=1,#af do ai=math.max(ai,#af[aj].s)end;while 1 do local U,T,ak=_(J(D/2-(#af+2)/2),a0)+2;for aj=1,#af do T=J(C/2-#af[aj].s/2)if aj==ah then Q(J(C/2-ai/2)-2,U,ai+4,1,r)I(s)x(T,U,af[aj].s)else H(p)I(q)x(T,U,af[aj].s)end;U=U+1 end;ak={i()}if ak[1]==d then if ak[4]==200 and ah>1 then ah=ah-1 elseif ak[4]==208 and ah<#af then ah=ah+1 elseif ak[4]==28 then if af[ah].c then af[ah].c()end;if af[ah].b then return end end end end end,function(U,al)local N,am,an,ak,ao="",true;while 1 do an=al..N;y(1,U,C,1," ")x(J(C/2-#an/2),U,an..(am and"█"or""))ak={i(0.5)}if ak[1]==d then if ak[4]==28 then return N elseif ak[4]==14 then N=N:sub(1,-2)else ao=unicode.char(ak[3])if ao:match("^[%w%d%p%s]+")then N=N..ao end end;am=true elseif ak[1]=="clipboard"then N=N..ak[3]elseif not ak[1]then am=not am end end end,function(ap)local aq,aa,ac,ar,ae=function(N)_(G,b,"Internet boot failed: "..N,1)end,"",g(v).request(ap)if ac then _(G,b,"Downloading script...")while 1 do ar,ae=ac.read(n)if ar then aa=aa..ar else ac:close()if ae then aq(ae)else ar,ae=load(aa)if ar then z("#"..ap)ar,ae=pcall(ar)if ar then return else aq(ae)end else aq(ae)end end;break end end else aq("invalid URL-address")end end;_(G,a,"Hold Alt to show boot options menu")local as,ak=j()+1;while j()<as do ak={i(as-j())}if ak[1]==d and ak[4]==56 then local at={S("Disk management",function()local au,av={a5()},A()for aw in h(f)do local a9=g(aw)local ax,ay=a9.getLabel()or"Unnamed",a9.isReadOnly()k(au,1,S((aw==av and"> "or" ")..K(ax,10)..K(a9.spaceTotal()>1048576 and"HDD"or a9.spaceTotal()>65536 and"FDD"or"SYS",3)..K(ay and"R"or"R/W",3)..aw:sub(1,8).." "..K(string.format("%.2f",a9.spaceUsed()/a9.spaceTotal()*100).."%",6,1),function()local az={a5()}if not ay then k(az,1,S(c,function()a9.setLabel(a7(_(G,c)+2,"Enter new name: "))end,1))k(az,2,S("Format",function()_(G,a,"Formatting filesystem "..aw)for aA,aB in ipairs(a9.list("/"))do a9.remove(aB)end;_(G,a,"Formatting finished",1)end,1))end;if a9.exists(e)then k(az,1,S("Set as startup",function()z(aw)end,1))end;a6(ax.." ("..aw..")",az)end,1))end;a6("Select filesystem to show options",au)end),S("Shutdown",function()w()end),a5()}if v then k(at,2,S(b,function()a8(a7(_(G,b)+2,"Enter URL: "))end))end;a6(a,at)end end;local aa,a9=A()if aa:sub(1,1)=="#"then a8(aa:sub(2,-1))else a9=g(aa)if a9 and a9.exists(e)then a4(a9)else for aw in h(f)do a9=g(aw)if a9.exists(e)then z(aw)a4(a9)break else a9=nil end end;if not a9 then _(G,a,"No bootable mediums found",1)end end end;w()
|
||||
Loading…
x
Reference in New Issue
Block a user