Test install script

This commit is contained in:
Christopher Cookman 2024-10-27 16:31:05 -06:00
parent 58cff5be78
commit 944ad4d679
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

18
install.lua Normal file
View file

@ -0,0 +1,18 @@
fs.makeDir("/ccryptolib") -- Make folder structure
function downloadDir(dir)
local data = textutils.unserialiseJSON(http.get("https://git.chrischro.me/api/v1/repos/ChrisChrome/ccryptolib/contents/" .. dir).readAll())
for _,entry in ipairs(data) do
if entry.type == "file" then -- We're gonna download it
print("Downloading " .. entry.name)
local file = http.get(entry.download_url).readAll()
local newFile = fs.open("/" .. entry.path, "w")
newFile.write(file)
newFile.close()
elseif entry.type == "dir" then
downloadDir(entry.path)
end
end
end
downloadDir("ccryptolib")