IgorTimofeev

MineOS installer

Jan 13th, 2024 (edited)
25,207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.77 KB | None | 0 0
  1. local component = require("component")
  2. local computer = require("computer")
  3. local os = require("os")
  4.  
  5. local gpu = component.gpu
  6.  
  7. -- Checking if computer is tough enough for such a S T Y L I S H product as MineOS
  8. do
  9.     local potatoes = {}
  10.  
  11.     -- GPU/screen
  12.     if gpu.getDepth() < 8 or gpu.maxResolution() < 160 then
  13.         table.insert(potatoes, "Tier 3 graphics card and screen");
  14.     end
  15.  
  16.     -- RAM
  17.     if computer.totalMemory() < 2 * 1024 * 1024 then
  18.         table.insert(potatoes, "At least 2x tier 3.5 RAM modules");
  19.     end
  20.  
  21.     -- HDD
  22.     do
  23.         local filesystemFound = false
  24.  
  25.         for address in component.list("filesystem") do
  26.             if component.invoke(address, "spaceTotal") >= 2 * 1024 * 1024 then
  27.                 filesystemFound = true
  28.                 break
  29.             end
  30.         end
  31.  
  32.         if not filesystemFound then
  33.             table.insert(potatoes, "At least tier 2 hard disk drive");
  34.         end
  35.     end
  36.  
  37.     -- Internet
  38.     if not component.isAvailable("internet") then
  39.         table.insert(potatoes, "Internet card");
  40.     end
  41.  
  42.     -- EEPROM
  43.     if not component.isAvailable("eeprom") then
  44.         table.insert(potatoes, "EEPROM");
  45.     end
  46.  
  47.     -- SORRY BRO NOT TODAY
  48.     if #potatoes > 0 then
  49.         print("Your computer does not meet the minimum system requirements:")
  50.  
  51.         for i = 1, #potatoes do
  52.             print("  ⨯ " .. potatoes[i])
  53.         end
  54.  
  55.         return
  56.     end
  57. end
  58.  
  59. -- Checking if installer can be downloaded from GitHub, because of PKIX errors, server blacklists, etc
  60. do
  61.     local success, result = pcall(component.internet.request, "https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Installer/Main.lua")
  62.    
  63.     if not success then
  64.         if result then
  65.             print("Download servers are unavailable: " .. tostring(result))
  66.         else
  67.             print("Download servers are unavailable for unknown reasons")
  68.         end
  69.     end
  70.  
  71.     local deadline = computer.uptime() + 5
  72.     local message
  73.  
  74.     while computer.uptime() < deadline do
  75.         success, message = result.finishConnect()
  76.  
  77.         if success then
  78.             break
  79.         else
  80.             if message then
  81.                 break
  82.             else
  83.                 os.sleep(0.1)
  84.             end
  85.         end
  86.     end
  87.  
  88.     result.close()
  89.  
  90.     if not success then
  91.         if message then
  92.             if message:match("PKIX") then
  93.                 local foreground = gpu.getForeground()
  94.                 gpu.setForeground(0x00AAFF)
  95.  
  96.                 print [[  __  _____  ___  ___ __________     _____ _   _____ ]]
  97.                 print [[ / / / / _ \/ _ \/ _ /_  __/ __/ __ / / _ | | / / _ |]]
  98.                 print [[/ /_/ / ___/ // / __ |/ / / _/  / // / __ | |/ / __ |]]
  99.                 print [[\____/_/  /____/_/ |_/_/ /___/  \___/_/ |_|___/_/ |_|]]
  100.                 print ""
  101.            
  102.                 gpu.setForeground(foreground)
  103.                 print "The Java version you are using is VERY outdated. It won't allow you to download any files over HTTPS due to outdated SSL certificates. Here are some steps to solve this problem:"
  104.                 print "• If you're in single player mode, just get latest Java 8 release from java.com/download"
  105.                 print "• If you're using an \"unofficial\" launcher, check its settings and make sure that it uses the latest Java 8 release"
  106.                 print "• If you're seeing this on a public server, the only thing you can do is to tell server owner to update Java on his side"
  107.             else
  108.                 print("Download servers are unavailable: " .. tostring(result))
  109.             end
  110.         else
  111.             print("Download servers are unavailable for unknown reasons")
  112.         end
  113.  
  114.         return
  115.     end
  116. end
  117.  
  118. -- Flashing EEPROM with tiny script that will run installer itself after reboot.
  119. -- It's necessary, because we need clean computer without OpenOS hooks to computer.pullSignal()
  120. component.eeprom.set([[
  121.     local connection, data, chunk = component.proxy(component.list("internet")()).request("https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Installer/Main.lua"), ""
  122.    
  123.     while true do
  124.         chunk = connection.read(math.huge)
  125.        
  126.         if chunk then
  127.             data = data .. chunk
  128.         else
  129.             break
  130.         end
  131.     end
  132.    
  133.     connection.close()
  134.    
  135.     load(data)()
  136. ]])
  137.  
  138. computer.shutdown(true)
  139.  
Tags: MineOs
Advertisement
Add Comment
Please, Sign In to add comment