minif

installer

Jan 23rd, 2020 (edited)
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. --Minif OS Installer
  2. --Functions and Variables
  3.  
  4. launchScreenSizeX, launchScreenSizeY = term.getSize()
  5. function launchFillBG(selColor)
  6. paintutils.drawFilledBox(1,1,launchScreenSizeX,launchScreenSizeY,selColor)
  7. term.setCursorPos(1,1)
  8. term.setBackgroundColor(selColor)
  9. if selColor == colors.white then
  10. term.setTextColor(colors.black)
  11. else
  12. term.setTextColor(colors.white)
  13. end
  14. end
  15.  
  16. function launchInstall(code)
  17. fs.delete("temp/install")
  18. shell.run("pastebin get "..code.." /temp/install")
  19. if fs.exists("/temp/install") then
  20. local file = fs.open("/temp/install","r")
  21. print("Installing "..file.readLine())
  22. local noFiles = file.readLine()
  23. print("Total Files: ".. noFiles)
  24. for i=1,tonumber(noFiles) do
  25. local ncode = file.readLine()
  26. local location = file.readLine()
  27. fs.delete(location)
  28. shell.run("pastebin get "..ncode.." "..location)
  29. if fs.exists(location) then
  30. print("Success")
  31. else
  32. print("Failure")
  33. end
  34. end
  35. file.close()
  36. else
  37. print("File Map Failure")
  38. end
  39. end
  40.  
  41. function installNumber(version)
  42. print("installing".. version)
  43. fs.delete("temp/versions")
  44. shell.run("pastebin get vczUSAiy /temp/versions")
  45. if fs.exists("/temp/versions") then
  46. local file = fs.open("/temp/versions","r")
  47. print("Latest Version: "..file.readLine())
  48. local noVersions = file.readLine()
  49. print("Total Versions: "..noVersions)
  50. for i=1, tonumber(noVersions) do
  51. local nversion = file.readLine()
  52. local code = file.readLine()
  53. if nversion == version then
  54. print("Installing: "..version)
  55. launchInstall(code)
  56. end
  57. end
  58. file.close()
  59. else
  60. print("Version Failure")
  61. end
  62. end
  63.  
  64.  
  65. --Execution
  66. launchFillBG(colors.cyan)
  67.  
  68. fs.delete("temp/versions")
  69. shell.run("pastebin get vczUSAiy /temp/versions")
  70. if fs.exists("/temp/versions") then
  71. local file = fs.open("/temp/versions","r")
  72. print("Latest Version: "..file.readLine())
  73. local noVersions = file.readLine()
  74. print("Total Versions: "..noVersions)
  75. for i=1, tonumber(noVersions) do
  76. local nversion = file.readLine()
  77. local code = file.readLine()
  78. print(i..": ".. nversion)
  79. end
  80. file.close()
  81. local choose = read()
  82. installNumber(choose)
  83. else
  84. print("Version Failure")
  85. end
  86.  
  87.  
  88.  
  89. sleep(2)
  90. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment