Fix installer

This commit is contained in:
Alessandro Proto 2024-08-20 18:28:46 +02:00
parent c75639eb2d
commit 1937b0ef79

View file

@ -48,7 +48,7 @@ local files = {
["src/startup.lua"] = "/startup.lua",
}
local githubUser = "CC-Legacy"
local githubUser = "Legacy-CC"
local githubRepo = "sPhone"
local githubBranch = "master"
@ -106,9 +106,9 @@ local function get(user, repo, bran, path, save)
error("not enough arguments, expected 4 or 5", 2)
end
local url = "https://git.alexdevs.me/"..user.."/"..repo.."/raw/branch/"..bran.."/"..path
local remote = http.get(url)
local remote, err = http.get(url)
if not remote then
return false
return nil, err
end
local text = remote.readAll()
remote.close()
@ -185,15 +185,15 @@ for k, v in pairs(files) do
term.setCursorPos(1,12)
term.clearLine()
center(" "..filesDownloaded.."/"..fileCount, 12)
local ok = k:sub(1, 4) == "ext:" and httpGet(k:sub(5), v) or getFile(k, v)
local ok, err = getFile(k, v)
if not ok then
if term.isColor() then
term.setTextColor(colors.red)
end
term.setCursorPos(2, 16)
print("Error getting file:")
term.setCursorPos(2, 17)
print(k)
term.setCursorPos(2, 17)
print(err)
sleep(1.5)
end
filesDownloaded = filesDownloaded + 1
@ -216,8 +216,8 @@ local f = fs.open("/.sPhone/config/sPhone","w")
f.write(textutils.serialize(data))
f.close()
if not fs.exists("/startup") then
fs.copy("/.sPhone/startup","/startup")
if not fs.exists("/startup.lua") then
fs.copy("/.sPhone/startup.lua","/startup.lua")
end
center(" sPhone installed!",h-2)
center(" Rebooting...",h-1)