SuperRavenSn1per

RavenOS Installer

Sep 11th, 2020 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.58 KB | None | 0 0
  1. repoUrl = "https://raw.githubusercontent.com/SuperRavenSn1per/RavenOS/master/"
  2.  
  3. directories = {"rSystem", "rSystem/rStartup", "rSystem/rAPIs", "rSystem/rImages", "rSystem/rPrograms"}
  4. files = {"startup", "rSystem/rAPIs/rtext", "rSystem/login", "rSystem/createAccount", "rSystem/rImages/background1", "rSystem/rAPIs/background", "rSystem/desktop", "rSystem/rPrograms/settings"}
  5.  
  6. w, h = term.getSize()
  7.  
  8. function install(filename)
  9.   content = http.get(repoUrl..filename).readAll()
  10.   file = fs.open(filename, "w")
  11.   file.write(content)
  12.   file.close()
  13. end
  14.  
  15. function startInstall()
  16.   term.clear()
  17.   term.setCursorPos(1,1)
  18.   for i,dir in pairs (directories) do
  19.     fs.makeDir(dir)
  20.   end
  21.   for i,file in pairs(files) do
  22.     term.clear()
  23.     term.setCursorPos(w / 2 - string.len("RavenOS Installer") / 2 , 2)
  24.     print("RavenOS Installer")
  25.     term.setCursorPos(w / 2 - string.len("Installing..."..file) / 2 , h / 2 + 2)
  26.     percent = math.floor(i/#files * 100)
  27.     numberOfBars = math.floor(20 * percent / 100)
  28.     print("Installing..."..file)
  29.     print("")
  30.     term.setCursorPos(w / 2 - string.len("                    ") / 2 , h / 2)
  31.     term.setBackgroundColor(colors.green)
  32.     write("                    ")
  33.     term.setBackgroundColor(colors.black)
  34.     write(" "..percent.."%")
  35.     term.setCursorPos(w / 2 - string.len("                    ") / 2 , h / 2)
  36.     term.setBackgroundColor(colors.lime)
  37.     for i = 1,numberOfBars do
  38.       write(" ")
  39.     end
  40.     term.setBackgroundColor(colors.black)
  41.     install(file)
  42.   end
  43.   settings.set("syscolor", colors.green)
  44.   settings.set("highlightcolor", colors.lime)
  45.   settings.set("version", "0.1")
  46.   settings.set("useLogin", false)
  47.   settings.save("rSystem/settings")
  48.   fts = fs.open("firstTimeStart", "w")
  49.   fts.write("--Just a file to tell system that this is a new computer with RavenOS")
  50.   fts.close()
  51.   term.clear()
  52.   term.setCursorPos(1,1)
  53.   print("Installation complete... press any key to reboot")
  54.   os.pullEvent()
  55.   os.reboot()
  56. end
  57.  
  58. term.clear()
  59. term.setCursorPos(1,1)
  60. print("---------------------")
  61. print("| RavenOS Installer |")
  62. print("---------------------")
  63. term.setCursorPos(1,5)
  64. print("Are you sure you want to install RavenOS? (Y/n)")
  65. term.setTextColor(colors.red)
  66. print("Warning: Files will be deleted")
  67. term.setTextColor(colors.white)
  68. term.setCursorPos(1,8)
  69. while true do
  70.   write("> ")
  71.   input = read()
  72.   input = string.lower(input)
  73.   if input == "yes" or input == "ye" or input == "y" then
  74.     startInstall()
  75.   elseif input == "no" or input == "n" then
  76.     print("Installation cancelled")
  77.     break
  78.   end
  79. end
Add Comment
Please, Sign In to add comment