Z1maV1

boot.lua

Oct 20th, 2022 (edited)
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.47 KB | None | 0 0
  1. -- CRAFTLOADER BOOTABLE MEDIA
  2. os.pullEvent = os.pullEventRaw
  3.  
  4. settings.load()
  5.  
  6. local args = {...}
  7.  
  8. local function PrintDoneMsg()
  9.     term.setTextColor(colors.green)
  10.     print("Done.")
  11.     term.setTextColor(colors.white)
  12. end
  13.  
  14. local function MakeLog( message, error, whileRunning )
  15.     local file = fs.open("crash_report.log", "a")
  16.     file.write("[CRITICAL ERROR WHILE " .. whileRunning .. "]\n[ERROR] " .. error .. " : " .. message)
  17.     file.close()
  18. end
  19.  
  20.  
  21. if settings.get("bootFailed", 0) >= 3 then
  22.     if settings.get("runRecoveryProgram", false) == true then
  23.         if fs.exists("recovery.lua") then
  24.             shell.run("recovery.lua")
  25.         end
  26.     end
  27. end
  28.  
  29.  
  30. term.clear()
  31. term.setCursorPos(1,1)
  32.  
  33. print("Chacking device characteristics...")
  34.  
  35. if not term.isColor() then
  36.     shell.run("/bin/BSOD", "\"[DO:0005] Unsupported device\"")
  37. elseif turtle then
  38.     shell.run("/bin/BSOD", "\"[DO:0005] Unsupported device\"")
  39. elseif pocket then
  40.     shell.run("/bin/BSOD", "\"[DO:0005] Unsupported device\"")
  41. end
  42.  
  43. PrintDoneMsg()
  44.  
  45. print("Chacking file integrity...")
  46.  
  47. if not fs.exists("/boot/init") then
  48.     settings.set("bootFailed", settings.get("bootFailed", 0) + 1)
  49.     settings.save()
  50.     MakeLog("CRITICAL FILE DOES NOT EXIST", "DO:0003", "BOOTING")
  51.     shell.run("/bin/BSOD", "\"[DO:0003] Critical file corrupted\"")
  52. elseif not fs.exists("/bin/main") then
  53.     settings.set("bootFailed", settings.get("bootFailed", 0) + 1)
  54.     settings.save()
  55.     MakeLog("CRITICAL FILE DOES NOT EXIST", "DO:0003", "BOOTING")
  56.     shell.run("/bin/BSOD", "\"[DO:0003] Critical file corrupted\"")
  57. elseif not fs.exists("/bin/.UninstallDialog") then
  58.     settings.set("bootFailed", settings.get("bootFailed", 0) + 1)
  59.     settings.save()
  60.     MakeLog("CRITICAL FILE DOES NOT EXIST", "DO:0003", "BOOTING")
  61.     shell.run("/bin/BSOD", "\"[DO:0003] Critical file corrupted\"")
  62. elseif not fs.exists("/bin/.command") then
  63.     settings.set("bootFailed", settings.get("bootFailed", 0) + 1)
  64.     settings.save()
  65.     MakeLog("CRITICAL FILE DOES NOT EXIST", "DO:0003", "BOOTING")
  66.     shell.run("/bin/BSOD", "\"[DO:0003] Critical file corrupted\"")
  67. elseif not fs.exists("/bin/.programs") then
  68.     settings.set("bootFailed", settings.get("bootFailed", 0) + 1)
  69.     settings.save()
  70.     MakeLog("CRITICAL FILE DOES NOT EXIST", "DO:0003", "BOOTING")
  71.     shell.run("/bin/BSOD", "\"[DO:0003] Critical file corrupted\"")
  72. elseif not fs.exists("/bin/.shutdown") then
  73.     settings.set("bootFailed", settings.get("bootFailed", 0) + 1)
  74.     settings.save()
  75.     MakeLog("CRITICAL FILE DOES NOT EXIST", "DO:0003", "BOOTING")
  76.     shell.run("/bin/BSOD", "\"[DO:0003] Critical file corrupted\"")
  77. elseif not fs.exists("/bin/.uninstall") then
  78.     settings.set("bootFailed", settings.get("bootFailed", 0) + 1)
  79.     settings.save()
  80.     MakeLog("CRITICAL FILE DOES NOT EXIST", "DO:0003", "BOOTING")
  81.     shell.run("/bin/BSOD", "\"[DO:0003] Critical file corrupted\"")
  82. elseif not fs.exists("/bin/install") then
  83.     settings.set("bootFailed", settings.get("bootFailed", 0) + 1)
  84.     settings.save()
  85.     MakeLog("CRITICAL FILE DOES NOT EXIST", "DO:0003", "BOOTING")
  86.     shell.run("/bin/BSOD", "\"[DO:0003] Critical file corrupted\"")
  87. elseif not fs.exists("/bin/.sleep") then
  88.     settings.set("bootFailed", settings.get("bootFailed", 0) + 1)
  89.     settings.save()
  90.     MakeLog("CRITICAL FILE DOES NOT EXIST", "DO:0003", "BOOTING")
  91.     shell.run("/bin/BSOD", "\"[DO:0003] Critical file corrupted\"")
  92. end
  93.  
  94. PrintDoneMsg()
  95.  
  96. settings.set("bootFailed", 0)
  97.  
  98. print("Botting System...")
  99.  
  100. term.clear()
  101. term.setCursorPos(1,1)
  102.  
  103. settings.save()
  104.  
  105. shell.run("/boot/init", table.concat(args, " "))
Advertisement
Add Comment
Please, Sign In to add comment