From 944ad4d6791c6359d14239e99381830fafdee3b6 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sun, 27 Oct 2024 16:31:05 -0600 Subject: [PATCH] Test install script --- install.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 install.lua diff --git a/install.lua b/install.lua new file mode 100644 index 0000000..8fdee95 --- /dev/null +++ b/install.lua @@ -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") \ No newline at end of file