Advertisement
optimussnorr

Untitled

Nov 16th, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. --[ Boot Manager
  2.  
  3. ver = "v3"
  4.  
  5. local handle = assert(fs.open("osros/system/config.osc", "r"), "Couldn't load the configuration!")
  6. local input = handle.readAll()
  7. handle.close()
  8. local conf = textutils.unserialize(input)
  9. desktopBarColor = conf.dBarC
  10. safeBoot = conf.safeBoot
  11.  
  12. if safeBoot == "true" then
  13.  
  14. local function missing()
  15. term.setBackgroundColor(colors.red)
  16. term.clear()
  17. term.setCursorPos(1,1)
  18. term.setTextColor(1)
  19. print("One of the system files are missing!")
  20. print("The operating system will not boot without one.")
  21. print("Reinstall? [y/n]")
  22. write("> ")
  23. local reinstall = read()
  24. if reinstall == "y" then
  25. term.clear()
  26. term.setCursorPos(1,1)
  27. print("Reinstalling... (NOTHING HAPPENS, COMING IN NEXT VERSION)")
  28. --COMING SOON
  29. sleep(1)
  30. print("Complete.")
  31. sleep(2)
  32. os.reboot()
  33. elseif reinstall == "n" then
  34. print("Aborting boot.")
  35. sleep(1)
  36. shell.run("shell")
  37.  
  38. else
  39. write("> ")
  40. end
  41. end
  42.  
  43. term.clear()
  44. term.setCursorPos(1,1)
  45.  
  46. print("SafeBoot is enabled.")
  47. print("Veryfying system files...")
  48. sleep(0.2)
  49. if fs.exists("osros") then
  50. else
  51. missing()
  52. end
  53. if fs.exists("osros/system") then
  54. else
  55. missing()
  56. end
  57. if fs.exists("osros/system/desktop.ossf") then
  58. else
  59. missing()
  60. end
  61. if fs.exists("osros/system/filemang.ossf") then
  62. else
  63. missing()
  64. end
  65. if fs.exists("osros/system/progMang.ossf") then
  66. else
  67. missing()
  68. end
  69. if fs.exists("osros/system/settings.ossf") then
  70. else
  71. missing()
  72. end
  73. if fs.exists("osros/system/shell.trm") then
  74. else
  75. missing()
  76. end
  77.  
  78. print("Creating session file..")
  79. sleep(0.6)
  80.  
  81. if fs.exists("osros/system/session.sesf") then
  82. term.setBackgroundColor(colors.blue)
  83. term.clear()
  84. term.setCursorPos(1,1)
  85. term.setTextColor(colors.red)
  86. print("Woops! It's already there...")
  87. print("If you shutdown your computer with")
  88. print("CRTL+S then ignore this message, otherwise")
  89. print("your computer may have shutdown in a bad")
  90. print("way.")
  91. print("Press any key to boot normally (Booting SHELL)")
  92. local timer1 = os.startTimer(5)
  93. while true do
  94. event, parameter = os.pullEvent()
  95. if event == "timer" and parameter == timer1 then
  96. pressedAKey = false
  97. break
  98. elseif event == "key" then
  99. pressedAKey = true
  100. break
  101. end
  102. end
  103.  
  104. if pressedAKey then
  105. shell.run("osros/system/desktop.ossf")
  106. else
  107. term.clear()
  108. term.setCursorPos(1,1)
  109. term.setTextColor(colors.yellow)
  110. print("> Loading SHELL")
  111. term.setBackgroundColor(colors.black)
  112. term.clear()
  113. term.setCursorPos(1,1)
  114. sleep(0.3)
  115. shell.run("shell")
  116. end
  117.  
  118. else
  119. local session = fs.open("osros/system/session.sesf", "w")
  120. session.write("Loaded")
  121. session.close()
  122. shell.run("osros/system/desktop.ossf")
  123. end
  124.  
  125. elseif safeBoot == "false" then
  126. term.clear()
  127. term.setCursorPos(1,1)
  128. print("SafeBoot is NOT enabled!")
  129. print("Loading OSROS")
  130. sleep(1)
  131. shell.run("osros/system/desktop.ossf")
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement