Advertisement
Tatantyler

HDD Partitioning BIOS

Nov 14th, 2012
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.34 KB | None | 0 0
  1. -- KillaVanilla's useful BIOS replacement!
  2.  
  3. -- whoooooo old bios yeaaaaaaaaaaah
  4.  
  5. --[[
  6. -- Install safe versions of various library functions
  7. -- These will not put cfunctions on the stack, so don't break serialisation
  8. xpcall = function( _fn, _fnErrorHandler )
  9.     local typeT = type( _fn )
  10.     assert( typeT == "function", "bad argument #1 to xpcall (function expected, got "..typeT..")" )
  11.     local co = coroutine.create( _fn )
  12.     local tResults = { coroutine.resume( co ) }
  13.     while coroutine.status( co ) ~= "dead" do
  14.         tResults = { coroutine.resume( co, coroutine.yield() ) }
  15.     end
  16.     if tResults[1] == true then
  17.         return true, unpack( tResults, 2 )
  18.     else
  19.         return false, _fnErrorHandler( tResults[2] )
  20.     end
  21. end
  22.  
  23. pcall = function( _fn, ... )
  24.     local typeT = type( _fn )
  25.     assert( typeT == "function", "bad argument #1 to pcall (function expected, got "..typeT..")" )
  26.     local tArgs = { ... }
  27.     return xpcall(
  28.         function()
  29.             return _fn( unpack( tArgs ) )
  30.         end,
  31.         function( _error )
  32.             return _error
  33.         end
  34.     )
  35. end
  36. ]]
  37.  
  38. function pairs( _t )
  39.     local typeT = type( _t )
  40.     if typeT ~= "table" then
  41.         error( "bad argument #1 to pairs (table expected, got "..typeT..")", 2 )
  42.     end
  43.     return next, _t, nil
  44. end
  45.  
  46. function ipairs( _t )
  47.     local typeT = type( _t )
  48.     if typeT ~= "table" then
  49.         error( "bad argument #1 to ipairs (table expected, got "..typeT..")", 2 )
  50.     end
  51.     return function( t, var )
  52.         var = var + 1
  53.         local value = t[var]
  54.         if value == nil then
  55.             return
  56.         end
  57.         return var, value
  58.     end, _t, 0
  59. end
  60.  
  61. function coroutine.wrap( _fn )
  62.     local typeT = type( _fn )
  63.     if typeT ~= "function" then
  64.         error( "bad argument #1 to coroutine.wrap (function expected, got "..typeT..")", 2 )
  65.     end
  66.     local co = coroutine.create( _fn )
  67.     return function( ... )
  68.         local tResults = { coroutine.resume( co, ... ) }
  69.         if tResults[1] then
  70.             return unpack( tResults, 2 )
  71.         else
  72.             error( tResults[2], 2 )
  73.         end
  74.     end
  75. end
  76.  
  77. function string.gmatch( _s, _pattern )
  78.     local type1 = type( _s )
  79.     if type1 ~= "string" then
  80.         error( "bad argument #1 to string.gmatch (string expected, got "..type1..")", 2 )
  81.     end
  82.     local type2 = type( _pattern )
  83.     if type2 ~= "string" then
  84.         error( "bad argument #2 to string.gmatch (string expected, got "..type2..")", 2 )
  85.     end
  86.    
  87.     local nPos = 1
  88.     return function()
  89.         local nFirst, nLast = string.find( _s, _pattern, nPos )
  90.         if nFirst == nil then
  91.             return
  92.         end    
  93.         nPos = nLast + 1
  94.         return string.match( _s, _pattern, nFirst )
  95.     end
  96. end
  97.  
  98. local nativesetmetatable = setmetatable
  99. function setmetatable( _o, _t )
  100.     if _t and type(_t) == "table" then
  101.         local idx = rawget( _t, "__index" )
  102.         if idx and type( idx ) == "table" then
  103.             rawset( _t, "__index", function( t, k ) return idx[k] end )
  104.         end
  105.         local newidx = rawget( _t, "__newindex" )
  106.         if newidx and type( newidx ) == "table" then
  107.             rawset( _t, "__newindex", function( t, k, v ) newidx[k] = v end )
  108.         end
  109.     end
  110.     return nativesetmetatable( _o, _t )
  111. end
  112.  
  113. -- Install lua parts of the os api
  114. function os.version()
  115.     if turtle then
  116.         return "TurtleOS 1.4"
  117.     end
  118.     return "CraftOS 1.4"
  119. end
  120.  
  121. function os.pullEventRaw( _sFilter )
  122.     return coroutine.yield( _sFilter )
  123. end
  124.  
  125. function os.pullEvent( _sFilter )
  126.     local event, p1, p2, p3, p4, p5 = os.pullEventRaw( _sFilter )
  127.     if event == "terminate" then
  128.         printError( "Terminated" )
  129.         error()
  130.     end
  131.     return event, p1, p2, p3, p4, p5
  132. end
  133.  
  134. -- Install globals
  135. function sleep( _nTime )
  136.     local timer = os.startTimer( _nTime )
  137.     repeat
  138.         local sEvent, param = os.pullEvent( "timer" )
  139.     until param == timer
  140. end
  141.  
  142. function write( sText )
  143.     local w,h = term.getSize()     
  144.     local x,y = term.getCursorPos()
  145.    
  146.     local nLinesPrinted = 0
  147.     local function newLine()
  148.         if y + 1 <= h then
  149.             term.setCursorPos(1, y + 1)
  150.         else
  151.             term.setCursorPos(1, h)
  152.             term.scroll(1)
  153.         end
  154.         x, y = term.getCursorPos()
  155.         nLinesPrinted = nLinesPrinted + 1
  156.     end
  157.    
  158.     -- Print the line with proper word wrapping
  159.     while string.len(sText) > 0 do
  160.         local whitespace = string.match( sText, "^[ \t]+" )
  161.         if whitespace then
  162.             -- Print whitespace
  163.             term.write( whitespace )
  164.             x,y = term.getCursorPos()
  165.             sText = string.sub( sText, string.len(whitespace) + 1 )
  166.         end
  167.        
  168.         local newline = string.match( sText, "^\n" )
  169.         if newline then
  170.             -- Print newlines
  171.             newLine()
  172.             sText = string.sub( sText, 2 )
  173.         end
  174.        
  175.         local text = string.match( sText, "^[^ \t\n]+" )
  176.         if text then
  177.             sText = string.sub( sText, string.len(text) + 1 )
  178.             if string.len(text) > w then
  179.                 -- Print a multiline word              
  180.                 while string.len( text ) > 0 do
  181.                     if x > w then
  182.                         newLine()
  183.                     end
  184.                     term.write( text )
  185.                     text = string.sub( text, (w-x) + 2 )
  186.                     x,y = term.getCursorPos()
  187.                 end
  188.             else
  189.                 -- Print a word normally
  190.                 if x + string.len(text) - 1 > w then
  191.                     newLine()
  192.                 end
  193.                 term.write( text )
  194.                 x,y = term.getCursorPos()
  195.             end
  196.         end
  197.     end
  198.    
  199.     return nLinesPrinted
  200. end
  201.  
  202. function print( ... )
  203.     local nLinesPrinted = 0
  204.     for n,v in ipairs( { ... } ) do
  205.         nLinesPrinted = nLinesPrinted + write( tostring( v ) )
  206.     end
  207.     nLinesPrinted = nLinesPrinted + write( "\n" )
  208.     return nLinesPrinted
  209. end
  210.  
  211. function printError( ... )
  212.     if term.isColour() then
  213.         term.setTextColour( colours.red )
  214.     end
  215.     print( ... )
  216.     term.setTextColour( colours.white )
  217. end
  218.  
  219. function read( _sReplaceChar, _tHistory )
  220.     term.setCursorBlink( true )
  221.  
  222.     local sLine = ""
  223.     local nHistoryPos = nil
  224.     local nPos = 0
  225.     if _sReplaceChar then
  226.         _sReplaceChar = string.sub( _sReplaceChar, 1, 1 )
  227.     end
  228.    
  229.     local w, h = term.getSize()
  230.     local sx, sy = term.getCursorPos() 
  231.    
  232.     local function redraw( _sCustomReplaceChar )
  233.         local nScroll = 0
  234.         if sx + nPos >= w then
  235.             nScroll = (sx + nPos) - w
  236.         end
  237.            
  238.         term.setCursorPos( sx, sy )
  239.         local sReplace = _sCustomReplaceChar or _sReplaceChar
  240.         if sReplace then
  241.             term.write( string.rep(sReplace, string.len(sLine) - nScroll) )
  242.         else
  243.             term.write( string.sub( sLine, nScroll + 1 ) )
  244.         end
  245.         term.setCursorPos( sx + nPos - nScroll, sy )
  246.     end
  247.    
  248.     while true do
  249.         local sEvent, param = os.pullEvent()
  250.         if sEvent == "char" then
  251.             sLine = string.sub( sLine, 1, nPos ) .. param .. string.sub( sLine, nPos + 1 )
  252.             nPos = nPos + 1
  253.             redraw()
  254.            
  255.         elseif sEvent == "key" then
  256.             if param == keys.enter then
  257.                 -- Enter
  258.                 break
  259.                
  260.             elseif param == keys.left then
  261.                 -- Left
  262.                 if nPos > 0 then
  263.                     nPos = nPos - 1
  264.                     redraw()
  265.                 end
  266.                
  267.             elseif param == keys.right then
  268.                 -- Right               
  269.                 if nPos < string.len(sLine) then
  270.                     nPos = nPos + 1
  271.                     redraw()
  272.                 end
  273.            
  274.             elseif param == keys.up or param == keys.down then
  275.                 -- Up or down
  276.                 if _tHistory then
  277.                     redraw(" ");
  278.                     if param == keys.up then
  279.                         -- Up
  280.                         if nHistoryPos == nil then
  281.                             if #_tHistory > 0 then
  282.                                 nHistoryPos = #_tHistory
  283.                             end
  284.                         elseif nHistoryPos > 1 then
  285.                             nHistoryPos = nHistoryPos - 1
  286.                         end
  287.                     else
  288.                         -- Down
  289.                         if nHistoryPos == #_tHistory then
  290.                             nHistoryPos = nil
  291.                         elseif nHistoryPos ~= nil then
  292.                             nHistoryPos = nHistoryPos + 1
  293.                         end                    
  294.                     end
  295.                    
  296.                     if nHistoryPos then
  297.                         sLine = _tHistory[nHistoryPos]
  298.                         nPos = string.len( sLine )
  299.                     else
  300.                         sLine = ""
  301.                         nPos = 0
  302.                     end
  303.                     redraw()
  304.                 end
  305.             elseif param == keys.backspace then
  306.                 -- Backspace
  307.                 if nPos > 0 then
  308.                     redraw(" ");
  309.                     sLine = string.sub( sLine, 1, nPos - 1 ) .. string.sub( sLine, nPos + 1 )
  310.                     nPos = nPos - 1                
  311.                     redraw()
  312.                 end
  313.             elseif param == keys.home then
  314.                 -- Home
  315.                 nPos = 0
  316.                 redraw()       
  317.             elseif param == keys.delete then
  318.                 if nPos < string.len(sLine) then
  319.                     redraw(" ");
  320.                     sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 )              
  321.                     redraw()
  322.                 end
  323.             elseif param == keys["end"] then
  324.                 -- End
  325.                 nPos = string.len(sLine)
  326.                 redraw()
  327.             end
  328.         end
  329.     end
  330.    
  331.     term.setCursorBlink( false )
  332.     term.setCursorPos( w + 1, sy )
  333.     print()
  334.    
  335.     return sLine
  336. end
  337.  
  338. loadfile = function( _sFile )
  339.     local file = fs.open( _sFile, "r" )
  340.     if file then
  341.         local func, err = loadstring( file.readAll(), fs.getName( _sFile ) )
  342.         file.close()
  343.         return func, err
  344.     end
  345.     return nil, "File not found"
  346. end
  347.  
  348. dofile = function( _sFile )
  349.     local fnFile, e = loadfile( _sFile )
  350.     if fnFile then
  351.         setfenv( fnFile, getfenv(2) )
  352.         return fnFile()
  353.     else
  354.         error( e, 2 )
  355.     end
  356. end
  357.  
  358. -- Install the rest of the OS api
  359. function os.run( _tEnv, _sPath, ... )
  360.     local tArgs = { ... }
  361.     local fnFile, err = loadfile( _sPath )
  362.     if fnFile then
  363.         local tEnv = _tEnv
  364.         --setmetatable( tEnv, { __index = function(t,k) return _G[k] end } )
  365.         setmetatable( tEnv, { __index = _G } )
  366.         setfenv( fnFile, tEnv )
  367.         local ok, err = pcall( function()
  368.             fnFile( unpack( tArgs ) )
  369.         end )
  370.         if not ok then
  371.             if err and err ~= "" then
  372.                 printError( err )
  373.             end
  374.             return false
  375.         end
  376.         return true
  377.     end
  378.     if err and err ~= "" then
  379.         printError( err )
  380.     end
  381.     return false
  382. end
  383.  
  384. local nativegetmetatable = getmetatable
  385. local nativetype = type
  386. local nativeerror = error
  387. function getmetatable( _t )
  388.     if nativetype( _t ) == "string" then
  389.         nativeerror( "Attempt to access string metatable", 2 )
  390.         return nil
  391.     end
  392.     return nativegetmetatable( _t )
  393. end
  394.  
  395. local tAPIsLoading = {}
  396. function os.loadAPI( _sPath )
  397.     local sName = fs.getName( _sPath )
  398.     if tAPIsLoading[sName] == true then
  399.         printError( "API "..sName.." is already being loaded" )
  400.         return false
  401.     end
  402.     tAPIsLoading[sName] = true
  403.        
  404.     local tEnv = {}
  405.     setmetatable( tEnv, { __index = _G } )
  406.     local fnAPI, err = loadfile( _sPath )
  407.     if fnAPI then
  408.         setfenv( fnAPI, tEnv )
  409.         fnAPI()
  410.     else
  411.         printError( err )
  412.         tAPIsLoading[sName] = nil
  413.         return false
  414.     end
  415.    
  416.     local tAPI = {}
  417.     for k,v in pairs( tEnv ) do
  418.         tAPI[k] =  v
  419.     end
  420.    
  421.     _G[sName] = tAPI   
  422.     tAPIsLoading[sName] = nil
  423.     return true
  424. end
  425.  
  426. function os.unloadAPI( _sName )
  427.     if _sName ~= "_G" and type(_G[_sName]) == "table" then
  428.         _G[_sName] = nil
  429.     end
  430. end
  431.  
  432. function os.sleep( _nTime )
  433.     sleep( _nTime )
  434. end
  435.  
  436. local nativeShutdown = os.shutdown
  437. function os.shutdown()
  438.     nativeShutdown()
  439.     while true do
  440.         coroutine.yield()
  441.     end
  442. end
  443.  
  444. -- Install the lua part of the HTTP api (if enabled)
  445. if http then
  446.     local function wrapRequest( _url, _post )
  447.         local requestID = http.request( _url, _post )
  448.         while true do
  449.             local event, param1, param2 = os.pullEvent()
  450.             if event == "http_success" and param1 == _url then
  451.                 return param2
  452.             elseif event == "http_failure" and param1 == _url then
  453.                 return nil
  454.             end
  455.         end    
  456.     end
  457.    
  458.     http.get = function( _url )
  459.         return wrapRequest( _url, nil )
  460.     end
  461.  
  462.     http.post = function( _url, _post )
  463.         return wrapRequest( _url, _post or "" )
  464.     end
  465. end
  466.  
  467. -- Install the lua part of the peripheral api
  468. peripheral.wrap = function( _sSide )
  469.     if peripheral.isPresent( _sSide ) then
  470.         local tMethods = peripheral.getMethods( _sSide )
  471.         local tResult = {}
  472.         for n,sMethod in ipairs( tMethods ) do
  473.             tResult[sMethod] = function( ... )
  474.                 return peripheral.call( _sSide, sMethod, ... )
  475.             end
  476.         end
  477.         return tResult
  478.     end
  479.     return nil
  480. end
  481.            
  482. -- Load APIs
  483. local tApis = fs.list( "rom/apis" )
  484. for n,sFile in ipairs( tApis ) do
  485.     if string.sub( sFile, 1, 1 ) ~= "." then
  486.         local sPath = fs.combine( "rom/apis", sFile )
  487.         if not fs.isDir( sPath ) then
  488.             os.loadAPI( sPath )
  489.         end
  490.     end
  491. end
  492.  
  493. if turtle then
  494.     local tApis = fs.list( "rom/apis/turtle" )
  495.     for n,sFile in ipairs( tApis ) do
  496.         if string.sub( sFile, 1, 1 ) ~= "." then
  497.             local sPath = fs.combine( "rom/apis/turtle", sFile )
  498.             if not fs.isDir( sPath ) then
  499.                 os.loadAPI( sPath )
  500.             end
  501.         end
  502.     end
  503. end
  504.  
  505. -- here's where my code starts:
  506.  
  507. print("Loading BIOS...")
  508.  
  509. local function doBoot()
  510.     local absDir = "A/"
  511.    
  512.     local oFS = {}
  513.     local drives = {}
  514.    
  515.     for i,v in ipairs(rs.getSides()) do
  516.         if peripheral.getType(v) == "drive" then
  517.             table.insert(drives, disk.getMountPath(v))
  518.         end
  519.     end
  520.    
  521.     for i,v in pairs(fs) do -- can't do oFS = fs, that breaks things
  522.         oFS[i] = v
  523.     end
  524.    
  525.     if not oFS.exists(absDir) then
  526.         oFS.makeDir(absDir)
  527.     end
  528.    
  529.     fs.list = function(path)
  530.         --print("lolol fs.list called: "..path)
  531.         if oFS.exists(path) then
  532.             --print("yes "..path.." does exist")
  533.             if fs.isReadOnly(path) and not (path == "" or path == "/") then
  534.                 --print("whoop de do "..path.." is in rom")
  535.                 return oFS.list(path)
  536.             else
  537.                 if string.sub(path, 1, 4) == "disk" then
  538.                     return oFS.list(path)
  539.                 end
  540.             end
  541.         end
  542.         if (path == "" or path == "/") and (absDir ~= "/") then
  543.             local files = oFS.list(fs.combine(absDir, path))
  544.             table.insert(files, "rom")
  545.             for i,v in ipairs(drives) do
  546.                 table.insert(files, v)
  547.             end
  548.             return files
  549.         end
  550.         return oFS.list(fs.combine(absDir, path))
  551.     end
  552.    
  553.     fs.exists = function(path)
  554.         if oFS.exists(path) then
  555.             if fs.isReadOnly(path) then
  556.                 return oFS.exists(path)
  557.             end
  558.         else
  559.             if string.sub(path, 1, 4) == "disk" then
  560.                 return oFS.exists(path)
  561.             end
  562.         end
  563.         return oFS.exists(fs.combine(absDir, path))
  564.     end
  565.    
  566.     fs.isDir = function(path)
  567.         if oFS.exists(path) then
  568.             if oFS.isDir(path) then
  569.                 return oFS.isDir(path)
  570.             end
  571.         else
  572.             if string.sub(path, 1, 4) == "disk" then
  573.                 return oFS.isDir(path)
  574.             end
  575.         end
  576.         return oFS.isDir(fs.combine(absDir, path))
  577.     end
  578.    
  579.     fs.getName = function(path)
  580.         if oFS.exists(path) then
  581.             if fs.isReadOnly(path) then
  582.                 return oFS.getName(path)
  583.             else
  584.                 if string.sub(path, 1, 4) == "disk" then
  585.                     return oFS.getName(path)
  586.                 end
  587.             end
  588.         end
  589.         return oFS.getName(fs.combine(absDir, path))
  590.     end
  591.    
  592.     fs.getDrive = function(path)
  593.         if oFS.exists(path) then
  594.             if fs.isReadOnly(path) then
  595.                 return oFS.getDrive(path)
  596.             else
  597.                 if string.sub(path, 1, 4) == "disk" then
  598.                     return oFS.getDrive(path)
  599.                 end
  600.             end
  601.         end
  602.         return oFS.getDrive(fs.combine(absDir, path))
  603.     end
  604.    
  605.     fs.getSize = function(path)
  606.         if oFS.exists(path) then
  607.             if fs.isReadOnly(path) then
  608.                 return oFS.getSize(path)
  609.             else
  610.                 if string.sub(path, 1, 4) == "disk" then
  611.                     return oFS.getSize(path)
  612.                 end
  613.             end
  614.         end
  615.         return oFS.getSize(fs.combine(absDir, path))
  616.     end
  617.    
  618.     fs.makeDir = function(path)
  619.         if oFS.exists(path) then
  620.             if fs.isReadOnly(path) then
  621.                 return oFS.makeDir(path)
  622.             else
  623.                 if string.sub(path, 1, 4) == "disk" then
  624.                     return oFS.makeDir(path)
  625.                 end
  626.             end
  627.         end
  628.         return oFS.makeDir(fs.combine(absDir, path))
  629.     end
  630.    
  631.     fs.delete = function(path)
  632.         if oFS.exists(path) then
  633.             if fs.isReadOnly(path) then
  634.                 return nil
  635.             else
  636.                 if string.sub(path, 1, 4) == "disk" then
  637.                     return oFS.delete(path)
  638.                 end
  639.             end
  640.         end
  641.         if path == "" or path == "/" then
  642.             return
  643.         end
  644.         return oFS.delete(fs.combine(absDir, path))
  645.     end
  646.    
  647.     fs.move = function(fromPath, toPath)
  648.         if oFS.exists(fromPath) then
  649.             if fs.isReadOnly(fromPath) then
  650.                 return nil
  651.             end
  652.         end
  653.         if string.sub(fromPath, 1, 4) ~= "disk" then
  654.             fromPath = fs.combine(absDir, fromPath)
  655.         end
  656.         if string.sub(toPath, 1, 4) ~= "disk" then
  657.             toPath = fs.combine(absDir, toPath)
  658.         end
  659.         if oFS.exists(toPath) then
  660.             return nil
  661.         end
  662.         return oFS.move(fromPath, toPath)
  663.     end
  664.    
  665.     fs.copy = function(fromPath, toPath)
  666.         if oFS.exists(fromPath) then
  667.             if fs.isReadOnly(fromPath) then
  668.                 return nil
  669.             end
  670.         end
  671.         if string.sub(fromPath, 1, 4) ~= "disk" then
  672.             fromPath = fs.combine(absDir, fromPath)
  673.         end
  674.         if string.sub(toPath, 1, 4) ~= "disk" then
  675.             toPath = fs.combine(absDir, toPath)
  676.         end
  677.         if oFS.exists(toPath) then
  678.             return nil
  679.         end
  680.         return oFS.copy(fromPath, toPath)
  681.     end
  682.    
  683.    
  684.     fs.open = function(path, mode)
  685.         if oFS.exists(path) then
  686.             if fs.isReadOnly(path) then
  687.                 return oFS.open(path, mode)
  688.             else
  689.                 if string.sub(path, 1, 4) == "disk" then
  690.                     return oFS.open(path, mode)
  691.                 end
  692.             end
  693.         end
  694.         return oFS.open(fs.combine(absDir, path), mode)
  695.     end
  696.    
  697.     local rawDrives = oFS.list("/")
  698.     local bootDrives = {}
  699.    
  700.     for i,v in ipairs(rawDrives) do
  701.         if v ~= "rom" then
  702.             table.insert(bootDrives, v)
  703.         end
  704.     end
  705.     table.insert(bootDrives, "Lua Interpreter (No Shell API)")
  706.  
  707.     term.clear()
  708.     term.setCursorPos(1,1)
  709.     print("Partitions / Devices found:")
  710.     for i,v in ipairs(bootDrives) do
  711.         if v ~= "Lua Interpreter (No Shell API)" then
  712.             if oFS.exists(fs.combine(v, "startup")) then
  713.                 print(i..". "..v.." (Has Startup File)")
  714.             else
  715.                 print(i..". "..v.." (No Startup File)")
  716.             end
  717.         else
  718.             print(i..". "..v)
  719.         end
  720.     end
  721.     local x,y = term.getCursorPos()
  722.     local bootDev = 0
  723.     while true do
  724.         term.setCursorPos(x,y)
  725.         write("boot>")
  726.         local device = read()
  727.         if tonumber(device) then
  728.             bootDev = tonumber(device)
  729.             if bootDrives[bootDev] then
  730.                 break
  731.             end
  732.         end
  733.     end
  734.     if bootDrives[bootDev] == "Lua Interpreter (No Shell API)" then
  735.         absDir = ""
  736.         os.run({}, "rom/programs/lua")
  737.     else
  738.         print("Booting to drive "..bootDrives[bootDev].."/ ...")
  739.         absDir = bootDrives[bootDev].."/"
  740.         os.sleep(1)
  741.         term.clear()
  742.         term.setCursorPos(1,1)
  743.         os.run({}, "rom/programs/shell")
  744.     end
  745. end
  746.  
  747. local status, err = pcall(doBoot)
  748.  
  749. if not status then
  750.     print("Critical Error:")
  751.     print(err)
  752.     print("Press any key to shutdown.")
  753.     os.pullEvent("key")
  754.     os.shutdown()
  755. else
  756.     print("Goodbye...")
  757.     os.sleep(1)
  758.     os.shutdown()
  759. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement