Advertisement
pepeknamornik

P7 All Updater

Jun 22nd, 2021 (edited)
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.78 KB | None | 0 0
  1. verze = "22.0224.R1"
  2. local tArgs = { ... }
  3. local w,h = term.getSize()
  4. local sum = 0
  5. local upd = 0
  6.  
  7. if fs.exists("/C/system/RAM/UpdateList.txt") then fs.delete("/C/system/RAM/UpdateList.txt") end
  8. term.setCursorPos(1,-5)
  9. shell.run ("pastebin get kXX84wM3 /C/system/RAM/UpdateList.txt")
  10.  
  11. if fs.exists("/C/system/RAM/online") then
  12.     local data = fs.open("/C/system/RAM/online", "r")
  13.     local Conser = data.readLine()
  14.         if (Conser == "pastebin.com") then PastebinMode = true  DevbinMode = false
  15.         elseif (Conser == "devbin.dev") then DevbinMode = true PastebinMode = false
  16.         else DevbinMode = false PastebinMode = false end
  17.     data.close()
  18. else DevbinMode = false PastebinMode = false end
  19.  
  20. local function logo()
  21. term.setBackgroundColor(colors.white)
  22. term.setTextColor(colors.blue)
  23. term.setCursorPos(w/2-5,h-1)
  24. write"  Pepek"
  25. term.setCursorPos(w/2+3,h-1)
  26. write"Soft  "
  27. term.setCursorPos(w/2+2,h-1)
  28. term.setTextColor(colors.lime)
  29. write"@"
  30. end
  31.  
  32. local function prc(text, y)
  33.   local w = term.getSize()
  34.   local _, cy = term.getCursorPos()
  35.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  36.   write(text)
  37. end
  38.  
  39.  function vycistit()
  40. term.setBackgroundColor(colors.white)
  41. term.setTextColor(colors.black)
  42. term.clear()
  43. prc ("Update all system files !", 5)
  44. prc ("Please wait...", h/2)
  45. prc ("Don't turn off your computer!", h/2+2)
  46. prc ("The computer will restart automatically.", h/2+4)
  47. logo()
  48. end
  49.  
  50. function updateCore(path, verze, Pcode, Dcode)
  51.     if fs.exists(path) then
  52.             term.setCursorPos(1,-5)
  53.             fs.delete(path)
  54.             shell.run("pastebin get "..Pcode.." "..path)
  55.         end
  56. end
  57.  
  58. function check()
  59.     if fs.exists("/C/system/RAM/UpdateList.txt") then
  60.         local data = fs.open("/C/system/RAM/UpdateList.txt", "r")
  61.         repeat
  62.         cesta = data.readLine()
  63.         verze = data.readLine()
  64.         Pcode = data.readLine()
  65.         Dcode = data.readLine()
  66.         local nic = data.readLine()
  67.         if cesta ~= nil and (string.sub(cesta,1,1) == "/") then
  68.             if fs.exists(cesta) then
  69.                 upd = upd + 1
  70.                 end
  71.             end
  72.         until cesta == nil
  73.         data.close()
  74.     end
  75. end
  76.  
  77. function ucheck()
  78.     if fs.exists("/C/system/RAM/UpdateList.txt") then
  79.         local data = fs.open("/C/system/RAM/UpdateList.txt", "r")
  80.         repeat
  81.         cesta = data.readLine()
  82.         verze = data.readLine()
  83.         Pcode = data.readLine()
  84.         Dcode = data.readLine()
  85.         local nic = data.readLine()
  86.         if cesta ~= nil and (string.sub(cesta,1,1) == "/") then
  87.             updateCore(cesta, verze, Pcode, Dcode)
  88.             if fs.exists(cesta) then
  89.             sum = sum +1
  90.             zprava = ("Completed "..sum.."/"..upd)
  91.             term.setTextColor(colors.black)
  92.             prc (zprava, h/2-4/2)
  93.             end
  94.         end
  95.         until cesta == nil
  96.         data.close()
  97.     end
  98.    
  99.    
  100.     if fs.exists("/C/system/RAM/UpdateList.txt") then fs.delete("/C/system/RAM/UpdateList.txt") end
  101.     sleep(2)
  102.     shell.run("/startup.lua reboot")
  103. end
  104.  
  105. vycistit()
  106. check()
  107. ucheck()
  108.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement