diff --git a/argentum.cfg b/argentum.cfg index e0b7495..b378c6b 100644 --- a/argentum.cfg +++ b/argentum.cfg @@ -1,7 +1,7 @@ local agcfg = { ["halyde"] = { ["maindir"] = "", - ["version"] = "2.7.2", + ["version"] = "2.8.0", ["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.", ["directories"] = { "halyde/apps", @@ -36,6 +36,7 @@ local agcfg = { "halyde/apps/helpdb/reboot.txt", "halyde/apps/helpdb/rm.txt", "halyde/apps/helpdb/shutdown.txt", + "halyde/apps/boot.lua", "halyde/apps/cat.lua", "halyde/apps/cd.lua", "halyde/apps/clear.lua", @@ -44,9 +45,12 @@ local agcfg = { "halyde/apps/echo.lua", "halyde/apps/fetch.lua", "halyde/apps/help.lua", + "halyde/apps/label.lua", "halyde/apps/ls.lua", "halyde/apps/lscor.lua", + "halyde/apps/lsdrv.lua", "halyde/apps/lua.lua", + "halyde/apps/maindrv.lua", "halyde/apps/mkdir.lua", "halyde/apps/mv.lua", "halyde/apps/reboot.lua", diff --git a/halyde/apps/boot.lua b/halyde/apps/boot.lua new file mode 100644 index 0000000..d08ef3d --- /dev/null +++ b/halyde/apps/boot.lua @@ -0,0 +1,60 @@ +local component = import("component") +local computer = import("computer") +local args = {...} + +local force = false + +local forceArgIdx = table.find(args,"-f") or table.find(args,"--force") +if forceArgIdx then + table.remove(args,forceArgIdx) + force = true +end + +local function getComponentID(str) + local function fromSlot(slot) + for i,v in component.list() do + if component.slot(i)==slot then + return i + end + end + end + if str=="hdd1" or str=="#1" then return fromSlot(5) end + if str=="hdd2" or str=="#2" then return fromSlot(6) end + if str=="floppy" or str=="#3" then return fromSlot(7) end + + if #str<3 then return nil,"Abbreviated ID must atleast have 3 characters" end + return component.get(str) +end + +local function fileExists(compID,file) + return component.invoke(compID,"exists",file) and not component.invoke(compID,"isDirectory",file) +end + +if type(args[1])=="string" then + local compID,err = getComponentID(args[1]) + if not compID then + print("\x1b[91mCould not get component ID from '"..args[1].."'.") + if type(err)=="string" then print("\x1b[91m"..err) end + return + end + if not force then + if componentlib.additions[compID] then + return print("\x1b[91mThis component is virtual and cannot be booted from directly.\nID: "..compID) + end + local type = component.type(compID) + if type~="filesystem" and type~="drive" then + return print("\x1b[91mThis component is not a storage medium.\nID: "..compID) + end + if type=="filesystem" and not fileExists(compID,"/init.lua") then + return print("\x1b[91mThis storage medium doesn't have an \"init.lua\" file.\nID: "..compID) + end + end + + computer.setBootAddress(compID) + if computer.getBootAddress()~=compID then + return print("\x1b[91mFailed to set the boot address.") + end + computer.shutdown(true) +else + shell.run("help boot") +end diff --git a/halyde/apps/helpdb/boot.txt b/halyde/apps/helpdb/boot.txt new file mode 100644 index 0000000..681fcd1 --- /dev/null +++ b/halyde/apps/helpdb/boot.txt @@ -0,0 +1,15 @@ +Usage: boot [ADDRESS] [FLAGS] +Restarts and automatically boots into any storage medium. Meant to be used for systems using a Lua BIOS EEPROM. + + ADDRESS The storage medium to boot to. + hdd1 The first hard drive inserted in the computer. + hdd2 The second hard drive inserted in the computer. + floppy The floppy disk that is inserted in the computer. + The ID of the component, abbreviated. Must have three or more characters. + FLAGS Specifies extra options when executing the command. + -f, --force Forces booting into the storage medium. + +Examples: + boot hdd1 Boot into the first hard drive inserted in the computer. + boot hdd2 Boot into the second hard drive inserted in the computer. + boot floppy Boot into the floppy disk inserted in the comuter. diff --git a/halyde/core/boot.lua b/halyde/core/boot.lua index 6f605c7..f0dd029 100644 --- a/halyde/core/boot.lua +++ b/halyde/core/boot.lua @@ -1,7 +1,7 @@ local loadfile = ... local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile) -_G._OSVERSION = "Halyde 2.7.2" +_G._OSVERSION = "Halyde 2.8.0" _G._OSLOGO = "" local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil repeat