Advertisement
Scoopta

ScaptOS3 Installer

Mar 13th, 2017 (edited)
1,393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. local _tarurl = "https://f.cloudninja.pw/vorbani/tar.lua"
  2. local function urequire(url)
  3.     local req, err, fail = http.get(url)
  4.     if not req then
  5.         error(err.." "..(fail or ""))
  6.     end
  7.     local contents = req.readAll()
  8.     local tbl = load(contents,"tar.lua","t")()
  9.     return tbl
  10. end
  11. local _tar = urequire(_tarurl)
  12. req,err,fail = http.get("https://mathis.pw/download")
  13. if not req then
  14.     error(err.." "..(fail or ""))
  15. end
  16. local tarFile = req.readAll()
  17. local tbl = _tar.list(tarFile)
  18. term.clear()
  19. term.setCursorPos(1,1)
  20. local topWin = window.create(term.native(),1,1,51,2)
  21. local botWin = window.create(term.native(),1,5,51,15)
  22. print("Vorbani will now be installed")
  23. print("The computer will reboot when done ")
  24. term.redirect(botWin)
  25. local TIME = os.time(os.date("*t"))
  26. for k,v in pairs(tbl) do
  27.     botWin.clear()
  28.     botWin.setCursorPos(1,1)
  29.     local percent = math.floor(k/#tbl*100)
  30.     print(tostring(percent).."% Completed")
  31.     if v:sub(#v) ~= "/" and not v:find("/") then
  32.         print("Creating file")
  33.         print(v)
  34.         local _file = _tar.open(tarFile,v)
  35.         local data = _tar.read(_file)
  36.         local file = fs.open("/"..v,"wb")
  37.         file.write(data)
  38.         file.close()
  39.     elseif v:sub(#v) == "/" then
  40.         print("Creating directory")
  41.         print(v)
  42.         fs.makeDir("/"..v)
  43.     else
  44.         local x,y = v:find("/[^/]*$")
  45.         local fName = v:sub(x+1)
  46.         local path = v:sub(1,x)
  47.         print("Creating file")
  48.         print(path..fName)
  49.         local _file = _tar.open(tarFile,v)
  50.         local data = _tar.read(_file)
  51.         local file = fs.open("/"..path..fName,"wb")
  52.         file.write(data)
  53.         file.close()
  54.     end
  55.     if k%5 == 0 then
  56.         sleep(0)
  57.     end
  58. end
  59. botWin.clear()
  60. botWin.setCursorPos(1,1)
  61. print("Install completed in "..(os.time(os.date("*t")))-TIME.." seconds")
  62. sleep(2)
  63. os.reboot()
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement