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