LexaDriver

Installer RedOS

Dec 2nd, 2018
1,341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.55 KB | None | 0 0
  1. local internet = require("internet")--Подключаем internet
  2. local io = require("io")
  3. local filesystem = require("filesystem")
  4. local computer = require("computer")
  5.  
  6. function split(s, delimiter) --Разделитель
  7.     result = {};
  8.     for match in (s..delimiter):gmatch("(.-)"..delimiter) do
  9.         table.insert(result, match);
  10.     end
  11.     return result;
  12. end
  13.  
  14. function download(url, directory)
  15.   filesystem.makeDirectory(directory)
  16.  
  17.   local filesStr = "" --Фалы
  18.  
  19.   for i in internet.request(url) do
  20.     filesStr = i --Получаем ссылки РЅР° фалы
  21.   end
  22.  
  23.   local files = split(filesStr,";") --Получаем массив
  24.  
  25.   for i=1,#files do
  26.     local value = ""
  27.     for i in internet.request(files[i]) do
  28.       value = value..i
  29.     end
  30.     local is, di = string.find(files[i], "/[^/]*$")
  31.     local filename = string.sub(files[i], is + 1)
  32.     local file = io.open(directory.."/"..filename,"w")
  33.     print(directory.."/"..filename) --Строчку использовать РїРѕ жиланию
  34.     file:write(value)
  35.     file:close()
  36.   end
  37. end
  38.  
  39.  
  40. print("Install RedOS 1.1? [Y/n]")
  41. local ans = io.read()
  42. if (ans == "Y") or (ans == "y") then
  43.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_1.1/master/Downloads/list_1.txt","/etc")
  44.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_1.1/master/Downloads/list_2.txt","/home")
  45.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_1.1/master/Downloads/list_3.txt","/lib/core")
  46.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_1.1/master/Downloads/list_4.txt","/lib")
  47.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_1.1/master/Downloads/list_5.txt","/RedOS")
  48.  
  49.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_1.1/master/Downloads/list_1.txt","/ISO/etc")
  50.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_1.1/master/Downloads/list_2.txt","/ISO/home")
  51.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_1.1/master/Downloads/list_3.txt","/ISO/lib/core")
  52.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_1.1/master/Downloads/list_4.txt","/ISO/lib")
  53.   download("https://raw.githubusercontent.com/LexaDriver/RedOS_1.1/master/Downloads/list_5.txt","/ISO/RedOS")
  54.  
  55.   print("Reboot now? [Y/n]")
  56.   ans = io.read()
  57.   if (ans == "Y") or (ans == "y") then
  58.     computer.shutdown(true)
  59.   end
  60. end
Add Comment
Please, Sign In to add comment