Skip to content
Permalink
beta
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
local debug=true
local ok,err,isOk,Error,func
if debug then print("Shell would be exiting") sleep(2) else shell.exit() end
local W, H = term.getSize()
if fs.exists(".OSRunner/rebootPath") then
local readReboot=fs.open(".OSRunner/rebootPath","r")
local dir=readReboot.readAll()
readReboot.close()
fs.delete(".OSRunner/rebootPath")
Sand(dir,fs.getName(dir))
end
local url=debug and "https://raw.github.com/MudkipTheEpic/ComputerCraft/beta/installer" or "https://raw.github.com/MudkipTheEpic/ComputerCraft/master/installer"
local function CenterPrint(Text, Line)
term.setCursorPos((W-#Text)/2, Line)
print(Text)
end
local function Sand(Dir, OSName, SetupFile, SetupURL)
local test=loadfile(".OSRunner/APIs/osrunner")
local sandbox=test()
return sandbox(Dir, OSName, SetupFile, SetupURL)
end
local reboot=function()
if not debug then return os.reboot() end
return false
end
local function showError(err)
--Neatly show the error, then ask for reinstall (NDF please do the fancy error showing screen. :P)
term.setBackgroundColor(colors.white)
term.clear()
term.setCursorPos(1,1)
printError(err)
os.pullEventRaw("key")
term.clear()
term.setCursorPos(1,1)
local ynM=paintutils.loadImage(".OSRunner/Resources/box")
paintutils.drawImage(ynM, 1, 1)
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
CenterPrint("Would you like to reinstall OSRunner",5)
CenterPrint("to attempt to fix this problem?",6)
CenterPrint("All OS'es will be kept.",7)
term.setBackgroundColor(colors.lime)
term.setCursorPos(7,11)
write(" Yes ")
term.setBackgroundColor(colors.red)
term.setCursorPos(40,11)
write(" No ")
while true do
local e,btn,x,y=os.pullEventRaw("mouse_click")
if (x>=7 and x<=12 and y==11) then
term.setBackgroundColor(colors.white)
CenterPrint("Reinstalling...",12)
fs.delete(".tempOS")
fs.delete(".tempKN")
fs.makeDir(".tempOS")
fs.makeDir(".tempKN")
for k,v in pairs(fs.list(".OSRunner/OSList")) do
fs.copy(".OSRunner/OSList/"..v, ".tempOS/"..v)
end
os.queueEvent("") coroutine.yield()
for k,v in pairs(fs.list(".OSRunner/Kernels")) do
fs.copy(".OSRunner/Kernels/"..v, ".tempKN/"..v)
end
os.queueEvent("") coroutine.yield()
local cake=http.get(url).readAll()
os.queueEvent("") coroutine.yield()
setfenv(loadstring(cake),getfenv())()
os.queueEvent("") coroutine.yield()
for k,v in pairs(fs.list(".tempOS")) do
if not fs.exists(".OSRunner/OSList/"..v) then fs.copy(".tempOS/"..v,".OSRunner/OSList/"..v) end
end
os.queueEvent("") coroutine.yield()
for k,v in pairs(fs.list(".tempKN")) do
fs.delete(".OSRunner/Kernels/"..v) fs.copy(".tempKN/"..v,".OSRunner/Kernels/"..v)
end
os.queueEvent("") coroutine.yield()
fs.delete(".tempOS")
fs.delete(".tempKN")
reboot()
break
elseif (x>=40 and x<=44 and y==11) then
reboot()
break
end
end
end
if debug then print("Initiating startup") sleep(2) end
ok,err=pcall(setfenv(loadfile(".OSRunner/Boot/startup"),getfenv()))
if not ok then showError(err) end
reboot()