Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- COS (Cat Operating System)
- Made by: MasterDisasterHD, Sxw1212,
- Thib0704, and Alakazard12
- File: install.lua
- Authors: Sxw1212
- Copyright COSTeam 2014
- ]]--
- print("CatOS installer v2.1")
- local baseURL
- if _G.COS and _G.COS.devMode then
- baseURL = "https://github.com/ComputerCraftTeam/COS/raw/master/"
- else
- baseURL = "https://github.com/ComputerCraftTeam/COS/raw/stable/"
- end
- if _G.COS and not _G.COS.devMode then
- local version = http.get("https://github.com/ComputerCraftTeam/COS/raw/stable/extra/version")
- if not version then
- print("Failed to get version")
- return
- end
- if version.readAll() == os.version() then
- print("Cat OS up-to-date")
- return
- end
- end
- local function get(url, file)
- local wh = http.get(url)
- if wh then
- local fh = fs.open(file, "w")
- fh.write(wh.readAll())
- fh.close()
- else
- print("Unable to fetch " .. file)
- end
- end
- local todelete = {
- "sys/bin", "sys/api", "sys/apps", "sys/assets"
- }
- local files = {
- ["startup"] = baseURL .. "extra/boot.lua",
- ["sys/"] = {
- ["cfg/"] = {
- ["version"] = baseURL .. "extra/version"
- },
- ["bin/"] = {
- ["update"] = baseURL .. "bin/update.lua",
- ["COS"] = baseURL .. "bin/cos.lua",
- ["springboard"] = baseURL .. "bin/springboard.lua",
- ["devmode"] = baseURL .. "bin/devmode.lua",
- ["compile"] = baseURL .. "bin/compile.lua",
- ["migrate"] = baseURL .. "bin/migrate.lua",
- ["run"] = baseURL .. "bin/run.lua",
- ["wget"] = baseURL .. "bin/wget.lua"
- },
- ["api/"] = {
- ["nova"] = baseURL .. "api/nova.lua",
- ["crypt"] = baseURL .. "api/crypt.lua",
- ["utils"] = baseURL .. "api/utils.lua"
- },
- ["apps/"] = {
- ["CatStore.app"] = baseURL .. "apps/CatStore.app"
- },
- ["assets/"] = {
- ["springboard/"] = {
- ["background.cpf"] = baseURL .. "assets/springboard/background.cpf"
- }
- },
- ["logs/"] = {
- }
- },
- ["home/"] = {
- ["apps/"] = {
- }
- },
- [".RUN_ENV"] = {
- }
- }
- local toget = {}
- local function map(list, path)
- for k, v in pairs(list) do
- if type(v) == "table" then
- fs.makeDir(path .. k)
- map(v, path .. k)
- else
- local file = {
- ["url"] = v,
- ["loc"] = path .. k
- }
- table.insert(toget, file)
- end
- end
- end
- map(files, "/")
- for k, v in pairs(todelete) do
- fs.delete(v)
- end
- local c = 0
- local x, y = term.getCursorPos()
- for k, v in pairs(toget) do
- term.clearLine()
- term.setCursorPos(x, y)
- write((#toget - c) .. " files to fetch")
- c = c + 1
- get(v.url, v.loc)
- end
- if not _G.COS then
- -- First Time install
- local fh = fs.open("/sys/cfg/filestructure", "w")
- fh.write("2")
- fh.close()
- end
- print("")
- print("Cat OS Updated")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement