 _G.shell = shell
function pasteDownload(id,file)
	if fs.exists(file) then
		fs.delete(file)
	end
	local download=http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode(id))
	local h=fs.open(file,"w")
	h.write(download.readAll())
	h.close()
	download.close()
end
function update()
	if fs.exists("Glass/UI/.config") then
	local h=fs.open("Glass/UI/.config","r")
	version=h.readLine()
	h.close()
	else versionnew=true
	version="New Install"
	shell.run("Glass/UI/main.lua")
	end
	local link=http.get("http://pastebin.com/raw.php?i=Anr8TuAQ")
	local version2=link.readAll()
	link.close()
	term.setCursorPos(2,2)
	term.setBackgroundColor(colors.lightBlue)
	print(version)
	if version==version2 then
		sleep(3)
	else
	if fs.exists("Glass/UI/.config") then
		fs.delete("Glass/UI/.config")
	end
	local h=fs.open("Glass/UI/.config","w")
	h.writeLine(version2)
	h.close()
	term.setBackgroundColor(colors.cyan)
	term.clear()
	term.setCursorPos(22,10)
	print("Updating..")
	pasteDownload("8KUaSZXu","Glass/UI/img/logo.img")
	pasteDownload("VnDBhezt","Glass/UI/main.lua") 
	pasteDownload("1bxqs2pH","Glass/UI/img/blank.img")
	pasteDownload("zP7wKYTZ","Glass/UI/img/creeper.wall")
	pasteDownload("5KTfSc2k","Glass/UI/img/hills.wall")
	pasteDownload("MmSwV8hc","Glass/UI/img/icon-1.ui")
	pasteDownload("zG45rejC","Glass/UI/img/icon-2.ui")
	pasteDownload("UJfJtTBH","Glass/UI/img/login.img")
	pasteDownload("8KUaSZXu","Glass/UI/img/logo.img")
	pasteDownload("Eq07YsZD","Glass/UI/img/main.img")
	pasteDownload("ZjWUEbnE","Glass/UI/img/ui.wall")
	pasteDownload("Jrj1TNTy","Glass/UI/img/creeper.ico")
	pasteDownload("mb8B8KRy","Glass/UI/img/ui.ico")
	pasteDownload("R7rky5R6","Glass/UI/img/hills.ico")
	pasteDownload("jmcpE6F2","Glass/APIs/sha256")
	pasteDownload("yUsK7LZm","Glass/UI/img/download.img")
	pasteDownload("Kj1NdUqf","Glass/files.app")
	pasteDownload("T4S8QFKB","Glass/UI/img/window.img")
	pasteDownload("GtnZ2CQS","Glass/paint_mod.lua")
	pasteDownload("CnD4MfPY","Glass/UI/img/template.img")
	pasteDownload("6C6anKAr","Glass/UI/img/purple.ico")
	pasteDownload("Y3nLf1eS","Glass/UI/img/purple.wall")
	pasteDownload("V6xe9c3R","startup")	
	version=version2
	os.reboot()
	end
end
local i=paintutils.loadImage("Glass/UI/img/hills.wall")
paintutils.drawImage(i,1,1)
local startimg=paintutils.loadImage("Glass/UI/img/logo.img")
paintutils.drawImage(startimg,1,1)
term.setCursorPos(20,15)
term.setBackgroundColor(colors.gray)
http.request("http://example.com")
test=true
while test==true do
	local event=os.pullEvent()
	if event=="http_success" then
		online=true
		test=false
	elseif event=="http_failure" then
		online=false
		test=false
	end
end
if version_new then
shell.run("Glass/UI/main.lua")
else if online then
	update()
	else term.setCursorPos(1,1)
		term.setBackgroundColor(colors.lightBlue)
		print(version)
		sleep(3)
	end
end
shell.run("Glass/UI/main.lua")