mirevall

CustomBios beta

Mar 24th, 2017 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function yNt()
  2. local n=1
  3. while true do
  4. local x, y=term.getCursorPos()
  5. term.clearLine()
  6. if n==1 then write(">No< Yes") else write (" No >Yes<") end
  7. term.setCursorPos(x, y)
  8. a, b=os.pullEvent("key")
  9. if b==263 and n==2 then n=1 end
  10. if b==262 and n==1 then n=2 end
  11. if b==257 then
  12. print("")
  13. if n==1 then return false end
  14. if n==2 then return true end
  15. end
  16. end
  17. end
  18.  
  19. function nYt()
  20. local n=2
  21. while true do
  22. local x, y=term.getCursorPos()
  23. term.clearLine()
  24. if n==1 then write(">No< Yes") else write (" No >Yes<") end
  25. term.setCursorPos(x, y)
  26. a, b=os.pullEvent("key")
  27. if b==263 and n==2 then n=1 end
  28. if b==262 and n==1 then n=2 end
  29. if b==257 then
  30. print("")
  31. if n==1 then return false end
  32. if n==2 then return true end
  33. end
  34. end
  35. end
  36. if fs.exists("/CB/CustomBiosUpdate") then
  37.  
  38. term.setTextColour(colours.white)
  39.  
  40. versions = fs.open("/CB/CustomBiosUpdate", "r")
  41. VCBios = versions.readLine()
  42. Vredstone = versions.readLine()
  43. Vdoorlock = versions.readLine()
  44. Vnasclient = versions.readLine()
  45. versions.close()
  46.  
  47. if not fs.exists("/CB/Prog/") then
  48. shell.run("mkdir /CB/Prog")
  49. end
  50.  
  51. if not fs.exists("/CB/Prog/ROEdit") then
  52. shell.run("pastebin get yRtcxB91 /CB/Prog/ROEdit")
  53. end
  54.  
  55. if not fs.exists("/mkNASserver") then
  56. launch = fs.open("/mkNASserver", "w")
  57. launch.write("write('Are you sure? (y or n) ')")
  58. launch.write("input = read()")
  59. launch.write("if input == 'y' then ")
  60. launch.write("shell.run('pastebin get 5WgxqxCv /CB/NAS')")
  61. launch.write("shell.run('/CB/NAS')")
  62. launch.write("end")
  63. launch.close()
  64. end
  65.  
  66. if not fs.exists("/redstone") then
  67. launch = fs.open("/redstone", "w")
  68. launch.write("shell.run('/CB/Prog/redstone')")
  69. launch.close()
  70. end
  71.  
  72. if not fs.exists("/NAS") then
  73. launch = fs.open("/NAS", "w")
  74. launch.write("shell.run('/CB/Prog/NAS')")
  75. launch.close()
  76. end
  77.  
  78. if not fs.exists("/doorlock") then
  79. Dlaunch = fs.open("/doorlock", "w")
  80. Dlaunch.write("shell.run('/CB/Prog/doorlock')")
  81. Dlaunch.close()
  82. end
  83.  
  84. if fs.exists ("/CB/Prog/NAS") then
  85. nas = fs.open("/CB/Prog/NAS", "r")
  86. Vanasclient = nas.readLine()
  87. nas.close()
  88. end
  89.  
  90. if fs.exists ("/CB/Prog/redstone") then
  91. red = fs.open("/CB/Prog/redstone", "r")
  92. Varedstone = red.readLine()
  93. red.close()
  94. end
  95.  
  96. if fs.exists ("/CB/Prog/doorlock") then
  97. dor = fs.open("/CB/Prog/doorlock", "r")
  98. Vadoorlock = dor.readLine()
  99. dor.close()
  100. end
  101.  
  102. if not fs.exists("/CB/Prog/redstone") or Varedstone ~= Vredstone then
  103. if fs.exists ("/CB/Prog/redstone") then
  104. fs.delete("/CB/Prog/redstone")
  105. end
  106. shell.run("pastebin get wVKudGMs /CB/Prog/redstone")
  107. term.setTextColour(colours.green)
  108. print("Redstone updated")
  109. os.sleep(0.5)
  110. term.setTextColour(colours.white)
  111. fs.delete("/CB/Files/PachNotes")
  112. pnotes = 1
  113. end
  114.  
  115. if not fs.exists("/CB/Prog/NAS") or Vanasclient ~= Vnasclient then
  116. if fs.exists ("/CB/Prog/NAS") then
  117. fs.delete("/CB/Prog/NAS")
  118. end
  119. shell.run("pastebin get 3aJs6E2C /CB/Prog/NAS")
  120. term.setTextColour(colours.green)
  121. print("NasClient updated")
  122. os.sleep(0.5)
  123. term.setTextColour(colours.white)
  124. fs.delete("/CB/Files/PachNotes")
  125. pnotes = 1
  126. end
  127.  
  128. if not fs.exists("/CB/Prog/doorlock") or Vadoorlock ~= Vdoorlock then
  129. if fs.exists ("/CB/Prog/doorlock") then
  130. fs.delete("/CB/Prog/doorlock")
  131. end
  132. shell.run("pastebin get QHa2NjJn /CB/Prog/doorlock")
  133. term.setTextColour(colours.green)
  134. print("DoorLock updated")
  135. os.sleep(0.5)
  136. term.setTextColour(colours.white)
  137. fs.delete("/CB/Files/PachNotes")
  138. pnotes = 1
  139. end
  140.  
  141. if not fs.exists("/CB/Files/PachNotes") or not fs.exists("/PNotes") then
  142. shell.run("pastebin get gCPerRc3 /CB/Files/PachNotes")
  143. term.setTextColour(colours.green)
  144. print("PachNotes updated")
  145. os.sleep(0.5)
  146. term.setTextColour(colours.white)
  147. pn = fs.open("/PNotes", "w")
  148. pn.writeLine("shell.run('/CB/Files/PachNotes')")
  149. pn.close()
  150. pnotes = 1
  151. end
  152.  
  153. end
  154.  
  155. term.setTextColour(colours.yellow)
  156. if not fs.exists ("/CB/password") then
  157. password = fs.open("/CB/password", "w")
  158. print ("Do you want to use a password ?")
  159. if yNt() == true then
  160. write("enter your password : ")
  161. local entrepass=read()
  162. write("confirm your password : ")
  163. local verifpass=read()
  164. if entrepass ~= verifpass then
  165. term.setTextColour(colours.red)
  166. print("passwords are not corresponding")
  167. password.close()
  168. fs.delete("/CB/password")
  169. os.sleep(2)
  170. os.reboot()
  171. end
  172. password.write(entrepass)
  173. password.close()
  174. term.setTextColour(colours.green)
  175. print("password is set.")
  176. os.sleep(2)
  177. os.reboot()
  178. end
  179.  
  180. print("Do you want to use a disk security ?")
  181. if yNt() == true then
  182. print("Insert a disk and press a key")
  183. local e, k = os.pullEvent( "key" )
  184. if not fs.exists("/disk/") then
  185. password.write("slt")
  186. password.close()
  187. fs.delete("/CB/password")
  188. print ("You need to insert a disk")
  189. os.sleep(2)
  190. os.reboot()
  191. end
  192. security = math.random(10000000000000)
  193. disksecure = fs.open("/CB/diskpass", "w")
  194. disksecure.write(security)
  195. disksecure.close()
  196. disquette = fs.open("/disk/secure", "w")
  197. disquette.write(security)
  198. disquette.close()
  199. password.write("disk")
  200. password.close()
  201. term.setTextColour(colours.green)
  202. print("Disk security set")
  203. os.sleep(2)
  204. os.reboot()
  205. end
  206. password.write("none")
  207. password.close()
  208. end
  209.  
  210.  
  211.  
  212. shell.run("clear")
  213. term.setTextColour(colours.blue)
  214. print 'Computercraft CustomBios V. 2.0.16'
  215. term.setTextColour(colours.brown)
  216.  
  217. testpass = fs.open("/CB/password", "r")
  218. local passwd = testpass.readLine()
  219. if passwd ~= "none" and passwd ~= "disk" then
  220. write("password : ")
  221. local pass=read("*")
  222. if pass ~= passwd then
  223. term.setTextColour(colours.red)
  224. print ("Indvalid password")
  225. testpass.close()
  226. os.sleep(2)
  227. os.reboot()
  228. end
  229. end
  230.  
  231. if passwd == "disk" then
  232. if not fs.exists("/disk/secure") then
  233. print("insert the security disk and press a key")
  234. local e, k = os.pullEvent( "key" )
  235. end
  236. if not fs.exists("/disk/secure") then
  237. term.setTextColour(colours.red)
  238. print("Wrong disk")
  239. os.sleep(2)
  240. os.reboot()
  241. end
  242.  
  243. disk = fs.open("/disk/secure", "r")
  244. passw = fs.open("/CB/diskpass", "r")
  245. disk2 = disk.readLine()
  246. passw2 = passw.readLine()
  247. if disk2 ~= passw2 then
  248. term.setTextColour(colours.red)
  249. print("Wrong disk")
  250. disk.close()
  251. passw.close()
  252. os.sleep(2)
  253. os.reboot()
  254. else
  255. term.setTextColour(colours.green)
  256. disk.close()
  257. passw.close()
  258. print("Disk OK")
  259. settings.set("shell.allow_disk_startup", false)
  260. term.setTextColour(colours.white)
  261. end
  262. end
  263. testpass.close()
  264.  
  265. term.setTextColour(colours.white)
  266. write 'Checking config'
  267. function Done()
  268. term.setTextColour(colours.green)
  269. os.sleep(0.25)
  270. print ' [done]'
  271. term.setTextColour(colours.white)
  272. end
  273.  
  274. function yN()
  275. local n=1
  276. local t=5
  277. os.startTimer(1)
  278. while true do
  279. local x, y=term.getCursorPos()
  280. term.clearLine()
  281. if n==1 then write(">CustomOS< CraftOS ") else write (" CustomOS >CraftOS< ") end
  282. term.setTextColour(colours.white)
  283. write(t)
  284. term.setTextColour(colours.red)
  285. term.setCursorPos(x, y)
  286. a, b=os.pullEvent()
  287. while a~="key" and a~="timer" do a, b=os.pullEvent() end
  288. if a=="timer" then
  289. t=t-1
  290. os.startTimer(1)
  291. end
  292. if t==-1 then print("") break end
  293. if b==263 and n==2 then n=1 end
  294. if b==262 and n==1 then n=2 end
  295. if b==257 then print("") break end
  296. end
  297. if n==1 then return true end
  298. if n==2 then return false end
  299. return false
  300. end
  301.  
  302. Done()
  303.  
  304. if fs.exists("/CB/doorlock") then
  305. shell.run("/CB/Prog/doorlock")
  306. end
  307.  
  308. if fs.exists("/CB/NAS") then
  309. shell.run("/CB/NAS")
  310. end
  311.  
  312. if not fs.exists("/CB/OSset") and term.isColor() then
  313. set = fs.open("/CB/OSset", "w")
  314. set.write("selected")
  315. set.close()
  316. write 'Checking type of computer'
  317. if pocket then
  318. Done()
  319. term.setTextColour(colours.red)
  320. print ("Do you want to install sPhone ?")
  321. if nYt() == true then
  322. shell.run("pastebin run HsJSnhKQ")
  323. end
  324. else
  325. Done()
  326. end
  327. term.setTextColour(colours.red)
  328. print ("Do you want to install OneOS ?")
  329. if nYt() == true then
  330. shell.run("pastebin run E1xftzLa")
  331. end
  332. else
  333. set = fs.open("/CB/OSset", "w")
  334. set.write("selected")
  335. set.close()
  336. end
  337. term.setTextColour(colours.white)
  338.  
  339. write 'Checking installed OS'
  340. if fs.exists("/startup") then
  341. Done()
  342. term.setTextColour(colours.red)
  343. if yN()==false then
  344. term.setTextColour(colours.white)
  345. write 'Loading OS'
  346. os.sleep(0.5)
  347. Done()
  348. if pnotes == 1 then
  349. os.sleep(0.5)
  350. term.setTextColour(colours.yellow)
  351. print ("To see Patch Notes, type 'PNotes'")
  352. term.setTextColour(colours.white)
  353. end
  354. shell.run("/rom/programs/shell")
  355. end
  356. term.setTextColour(colours.white)
  357.  
  358. if fs.exists("/System/main.lua") and not fs.exists("/CB/pach") then
  359. print ('Paching oneOS...')
  360. shell.run("rm /System/main.lua")
  361. shell.run("pastebin get Wb8SHJMA /System/main.lua")
  362. write 'Pached oneOS'
  363. patch = fs.open("/CB/pach", "w")
  364. patch.write("done")
  365. patch.close()
  366. Done()
  367. end
  368. else
  369. Done()
  370. end
  371.  
  372.  
  373. write 'Loading OS'
  374. os.sleep(0.5)
  375. Done()
  376. if pnotes == 1 then
  377. term.setTextColour(colours.yellow)
  378. print ("To see Patch Notes, type 'PNotes'")
  379. term.setTextColour(colours.white)
  380. end
  381. os.sleep(0.5)
Add Comment
Please, Sign In to add comment