SuperRavenSn1per

RavenPack Installer

Sep 9th, 2021 (edited)
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. local url = "https://raw.githubusercontent.com/SuperRavenSn1per/RavenPack/main/"
  2.  
  3. local files = {"ravenpack/rpu.lua", "rpu_loader.lua"}
  4.  
  5. local filesInstalled = 0
  6. local percent = 0
  7.  
  8. function install(file, fileName)
  9.     local dat = http.get(url..file).readAll()
  10.     local f = fs.open(fileName, "w")
  11.     f.write(dat)
  12.     f.close()
  13.     filesInstalled = filesInstalled + 1
  14.     percent = math.floor(filesInstalled / #files * 100)
  15.     print("Installing..."..file.." ("..percent.."%)")
  16. end
  17.  
  18. term.clear()
  19. term.setCursorPos(1,1)
  20. term.setTextColor(colors.orange)
  21.  
  22. print("-----------------------")
  23. print("| RavenPack Installer |")
  24. print("-----------------------")
  25. print("")
  26.  
  27. term.setTextColor(colors.white)
  28.  
  29. print("Would you like us to add our custom startup file? If not then you will have to run 'rpu_loader.lua' manually.")
  30. print("")
  31.  
  32. while true do
  33.     term.setTextColor(colors.red)
  34.     write("Y/N >> ")
  35.     term.setTextColor(colors.white)
  36.     local input = read()
  37.  
  38.     if string.lower(input) == "y" then
  39.         print("")
  40.         if fs.exists("startup") then
  41.             fs.delete("startup")
  42.         elseif fs.exists("startup.lua") then
  43.             fs.delete("startup.lua")
  44.         end
  45.         local sdat = http.get(url.."startup.lua").readAll()
  46.         local sf = fs.open("startup.lua", "w")
  47.         sf.write(sdat)
  48.         sf.close()
  49.         break
  50.     elseif string.lower(input) == "n" then
  51.         print("")
  52.         break
  53.     else
  54.         print("Invalid input... please enter (y/n)")
  55.     end
  56. end
  57.  
  58. term.clear()
  59. term.setCursorPos(1,1)
  60. term.setTextColor(colors.orange)
  61.  
  62. print("-----------------------")
  63. print("| RavenPack Installer |")
  64. print("-----------------------")
  65. print("")
  66.  
  67. term.setTextColor(colors.white)
  68.  
  69. print("Making directories...")
  70. fs.makeDir("ravenpack")
  71. for i,file in pairs(files) do
  72.     install(file, file)
  73. end
  74.  
  75. print("Installation finished. Would you like to reboot?")
  76. while true do
  77.     term.setTextColor(colors.red)
  78.     write("Y/N >> ")
  79.     term.setTextColor(colors.white)
  80.     local input = read()
  81.     if string.lower(input) == "y" then
  82.         print("Rebooting...")
  83.         sleep(1)
  84.         os.reboot()
  85.     elseif string.lower(input) == "n" then
  86.         term.clear()
  87.         term.setCursorPos(1,1)
  88.         print("RavenPack has successfully been installed!")
  89.         break
  90.     else
  91.         print("Invalid input... please enter (y/n)")
  92.     end
  93. end
  94.  
  95.  
Advertisement
Add Comment
Please, Sign In to add comment