ComputerCraft Archive

OmniOS - The OS than can do (almost) anything

computer operating-system unknown forum

Description

Hello fellow ComputerCrafters,for a long time I have been somewhat inactive on the forums. But there is a reason behind this: I can finally proudly present OmniOS. The last 5 months, OmniOS has been m...

Installation

Copy one of these commands into your ComputerCraft terminal:

Pastebin:pastebin get 2DMDuHci omnios_-_the_os_than_can_do_(almost)_anything
wget:wget https://pastebin.com/raw/2DMDuHci omnios_-_the_os_than_can_do_(almost)_anything
Archive:wget https://cc.shobie.xyz/cc/get/pb-2DMDuHci omnios_-_the_os_than_can_do_(almost)_anything
Quick Install: wget https://cc.shobie.xyz/cc/get/pb-2DMDuHci OmniOS - The OS than can do (almost) anything

Usage

Run the program after downloading

Tags

forumoperating-systems

Source

View Original Source

Code Preview

--[[
	OmniOS Installer
]]

term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.white)



print("Welcome to the OmniOS Installer.")
print("To proceed press enter.")
read("")


term.clear()
term.setCursorPos(1,1)

print("Fetching versions...")

local handle = http.get("http://pastebin.com/raw/TuBL454Z")
local data = handle.readAll()

print("Loading versions...")

local choices = loadstring(data)()
local max = #choices

local selection = 1

local w, h = term.getSize()

local function draw()
	term.clear()
	for i,v in pairs(choices) do
		if i == selection then
			term.setTextColor(colors.cyan)
			term.setCursorPos(math.floor((w-#v.name)/2 - 1), (i - selection) + math.floor(h/2))
			term.write("["..v.name.."]")
			term.setTextColor(colors.white)
		else
			term.setCursorPos(math.floor((w-#v.name)/2), (i - selection) + math.floor(h/2))
			term.write(v.name)
		end
	end
end

local function getURL(id)
	local url = choices[id].source
	if type(url) == "number" then
		return getURL(url)
	else
		return url
	end
end

local go = true

while go do
	draw()
	local e, id = os.pullEvent("key")
	if id == keys.up then
		selection = selection - 1
		if selection < 1 then
			selection = 1
		end
	elseif id == keys.down then
		selection = selection + 1
		if selection > max then
			selection = max
		end
	elseif id == keys.enter then
		break
	end
end

term.clear()
term.setCursorPos(1,1)

local url = getURL(selection)
print("Are you sure you want to proceed? <y/n>")

local r = read()

if r == "y" then
	local func = loadstring(http.get(url).readAll())
	setfenv(func,_G)
	func("OmniOS")
	print("Thank you for installing OmniOS.")
else
	print("Thank you for not installing OmniOS.")
	return
end

print("Do you wish to boot OmniOS on startup? <y/n>")

local r = read()

if r == "y" then
	if fs.exists("startup") then
		fs.copy("startup", "startupbackup")
	end
	local file = fs.open("startup", "w")
	file.write("dofile(\""..choices[selection].boot.."\")")
	file.close()
else
	print("Boot OmniOS by running "..choices[selection].boot)
end

print("Press ENTER to reboot")
read()
os.reboot()