Advertisement
LexaDriver

Installer_RedOS_indev

Mar 17th, 2019
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. local internet = require("internet")
  2. local io = require("io")
  3. local filesystem = require("filesystem")
  4. local computer = require("computer")
  5. local component = require("component")
  6. local disk = component.proxy(computer.getBootAddress())
  7.  
  8.  
  9. function split(inputstr, sep)
  10.         if sep == nil then
  11.                 sep = "%s"
  12.         end
  13.         local t={}
  14.         for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  15.                 table.insert(t, str)
  16.         end
  17.         return t
  18. end
  19.  
  20. function download(url, directory)
  21.   filesystem.makeDirectory(directory)
  22.  
  23.   local filesStr = ""
  24.  
  25.   for i in internet.request(url) do
  26.     filesStr = i
  27.   end
  28.  
  29.   local files = split(filesStr,"&")
  30.  
  31.   for i=1,#files do
  32.     local value = ""
  33.     for i in internet.request(files[i]) do
  34.       value = value..i
  35.     end
  36.     local is, di = string.find(files[i], "/[^/]*$")
  37.     local filename = string.sub(files[i], is + 1)
  38.     local file = io.open(directory.."/"..filename,"w")
  39.     print(directory.."/"..filename)
  40.     file:write(value)
  41.     file:close()
  42.   end
  43. end
  44.  
  45.  
  46. print("Install RedOS 1.2 [Beta]? [Y/n]")
  47. local ans = io.read()
  48. if (ans == "Y") or (ans == "y") then
  49.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_indev/master/Downloads/list_1.txt","/etc")
  50.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_indev/master/Downloads/list_2.txt","/home")
  51.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_indev/master/Downloads/list_3.txt","/lib/core")
  52.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_indev/master/Downloads/list_4.txt","/lib")
  53.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_indev/master/Downloads/list_5.txt","/RedOS")
  54.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_indev/master/Downloads/list_6.txt","/RedOS")
  55.   disk.setLabel("RedOS 1.2")
  56.   print("Reboot now? [Y/n]")
  57.   ans = io.read()
  58.   if (ans == "Y") or (ans == "y") then
  59.     computer.shutdown(true)
  60.   end
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement