Skip to content

Commit

Permalink
Added some checks for PKIX errors in OpenOS installer
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorTimofeev committed Jun 6, 2024
1 parent 33ead30 commit 26dec6f
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 33 deletions.
30 changes: 0 additions & 30 deletions Installer/BIOS.lua

This file was deleted.

122 changes: 122 additions & 0 deletions Installer/OpenOS.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
local component = require("component")
local computer = require("computer")
local os = require("os")

local gpu = component.gpu

-- Checking if computer is tough enough for such a S T Y L I S H product as MineOS
do
local potatoes = {}

-- GPU/screen
if gpu.getDepth() < 8 or gpu.maxResolution() < 160 then
table.insert(potatoes, "Tier 3 graphics card and screen");
end

-- RAM
if computer.totalMemory() < 2 * 1024 * 1024 then
table.insert(potatoes, "At least 2x tier 3.5 RAM modules");
end

-- HDD
do
local filesystemFound = false

for address in component.list("filesystem") do
if component.invoke(address, "spaceTotal") >= 2 * 1024 * 1024 then
filesystemFound = true
break
end
end

if not filesystemFound then
table.insert(potatoes, "At least tier 2 hard disk drive");
end
end

-- Internet
if not component.isAvailable("internet") then
table.insert(potatoes, "Internet card");
end

-- EEPROM
if not component.isAvailable("eeprom") then
table.insert(potatoes, "EEPROM");
end

-- SORRY BRO NOT TODAY
if #potatoes > 0 then
print("Your computer does not meet the minimum system requirements:")

for i = 1, #potatoes do
print("" .. potatoes[i])
end

return
end
end

-- Checking if installer can be downloaded from GitHub, because of PKIX errors, server blacklists, etc
do
local success, result = pcall(component.internet.request, "https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Installer/Main.lua")

if not success then
if result then
if result:match("PKIX") then
print("Download server SSL sertificate was rejected by Java. Update your Java version or install sertificate for github.com manually")
else
print("Download server is unavailable: " .. tostring(result))
end
else
print("Download server is unavailable for unknown reasons")
end

return
end

local deadline = computer.uptime() + 5
local message

while computer.uptime() < deadline do
success, message = result.finishConnect()

if success then
break
else
if message then
break
else
os.sleep(0.1)
end
end
end

result.close()

if not success then
print("Download server is unavailable. Check if github.com is not blocked by your internet provider or OpenComputers configuration file")
return
end
end

-- Flashing EEPROM with tiny script that will run installer itself after reboot.
-- It's necessary, because we need clean computer without OpenOS hooks to computer.pullSignal()
component.eeprom.set([[
local connection, data, chunk = component.proxy(component.list("internet")()).request("https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Installer/Main.lua"), ""
while true do
chunk = connection.read(math.huge)
if chunk then
data = data .. chunk
else
break
end
end
connection.close()
load(data)()
]])

computer.shutdown(true)
2 changes: 1 addition & 1 deletion README-ru_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ MineOS - это графическая операционная система

Если по какой-то причине ресурс pastebin для вас недоступен, используйте альтернативную команду для установки:

wget -f https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Installer/BIOS.lua /tmp/bios.lua && flash -q /tmp/bios.lua && reboot
wget -f https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Installer/OpenOS.lua /tmp/installer.lua && /tmp/installer.lua

Вы можете вставить её в консоль, используя среднюю кнопку мыши или кнопку Insert (по умолчанию). Спустя некоторое время запустится симпатичный установщик, где вам предложат выбрать предпочитаемый язык, загрузочный диск (можно отформатировать, если нужно), создать профиль пользователя и настроить несколько параметров под себя.

Expand Down
2 changes: 1 addition & 1 deletion README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MineOS是一个拥有GUI的操作系统,运行在Minecraft模组Open Computers

如果由于某种原因无法使用pastebin网站,请使用替代安装命令:

wget -f https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Installer/BIOS.lua /tmp/bios.lua && flash -q /tmp/bios.lua && reboot
wget -f https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Installer/OpenOS.lua /tmp/installer.lua && /tmp/installer.lua

过一会儿,一个制作优良的系统安装程序将会被启动。
安装程序将提示你选择你的首选语言、选择并格式化引导卷、创建用户配置文件并修改一些设置。
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The easiest way is to use default `pastebin` script. Insert an OpenOS floppy dis

If for some reason pastebin website is not available to you, use alternative installation command:

wget -f https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Installer/BIOS.lua /tmp/bios.lua && flash -q /tmp/bios.lua && reboot
wget -f https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Installer/OpenOS.lua /tmp/installer.lua && /tmp/installer.lua

You can paste it to console using middle mouse button or Insert key (by default). After a moment, a nice system installer will be shown. You will be prompted to select your preferred language, boot volume (can be formatted if needed), create a user profile and customize some settings

Expand Down

0 comments on commit 26dec6f

Please sign in to comment.