install script
This commit is contained in:
12
.vscode/settings.json
vendored
Normal file
12
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"Lua.workspace.library": [
|
||||||
|
"/home/ruffles/.vscode/extensions/pawz.polytoria-lua-1.1.1/api",
|
||||||
|
"${addons}/cc-tweaked/module/library"
|
||||||
|
],
|
||||||
|
"Lua.runtime.version": "Lua 5.3",
|
||||||
|
"Lua.runtime.builtin": {
|
||||||
|
"io": "disable",
|
||||||
|
"os": "disable"
|
||||||
|
},
|
||||||
|
"Lua.workspace.checkThirdParty": false
|
||||||
|
}
|
||||||
31
install.lua
Normal file
31
install.lua
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
local expect = require "cc.expect".expect
|
||||||
|
local base_url = "https://git.cadencoaster.com/Ruffles/smithy-printer/raw/branch/main/"
|
||||||
|
local function download_to(path)
|
||||||
|
expect(2, path, "string")
|
||||||
|
term.write(path)
|
||||||
|
if not http.checkURL(base_url..path) then error("URL is not valid" ,2) end
|
||||||
|
local data = http.get(base_url..path).readAll()
|
||||||
|
fs.makeDir(fs.getDir(path))
|
||||||
|
local file = fs.open(path,"w")
|
||||||
|
if not file then error("Failed to open file", 2) end
|
||||||
|
file.write(data)
|
||||||
|
file.close()
|
||||||
|
print(" OK")
|
||||||
|
end
|
||||||
|
|
||||||
|
local filesystem = {
|
||||||
|
files = {
|
||||||
|
"transforms.lua",
|
||||||
|
"startup.lua",
|
||||||
|
"libs/entrypointlib.lua",
|
||||||
|
"stratumDBlib.lua",
|
||||||
|
"meshnetBackend.lua",
|
||||||
|
},
|
||||||
|
dirs = {},
|
||||||
|
}for _,i in ipairs(filesystem.dirs) do
|
||||||
|
print("making dir",i)
|
||||||
|
fs.makeDir(i)
|
||||||
|
end
|
||||||
|
for _,i in ipairs(filesystem.files) do
|
||||||
|
download_to(i)
|
||||||
|
end
|
||||||
87
scan.lua
Normal file
87
scan.lua
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
local exceptions = {
|
||||||
|
["/scan.lua"] = true,
|
||||||
|
["scan.lua"] = true,
|
||||||
|
["/install.lua"] = true,
|
||||||
|
["install.lua"] = true,
|
||||||
|
["/.settings"] = true,
|
||||||
|
[".settings"] = true,
|
||||||
|
["/.git"] = true,
|
||||||
|
[".git"] = true,
|
||||||
|
["/rom"] = true,
|
||||||
|
["rom"] = true,
|
||||||
|
["/scan.dat"] = true,
|
||||||
|
["scan.dat"] = true,
|
||||||
|
["/.gitignore"] = true,
|
||||||
|
[".gitignore"] = true,
|
||||||
|
["/default_apps"] = true,
|
||||||
|
["default_apps"] = true,
|
||||||
|
[".vscode"] = true,
|
||||||
|
["/.vscode"] = true
|
||||||
|
}
|
||||||
|
local function scan(dir)
|
||||||
|
local out = {}
|
||||||
|
for _,i in ipairs(fs.list(dir)) do
|
||||||
|
local path = fs.combine(dir,i)
|
||||||
|
if exceptions[path] == nil then
|
||||||
|
if fs.isDir(path) then
|
||||||
|
out[i] = scan(path)
|
||||||
|
else
|
||||||
|
local file = fs.open(path,"r")
|
||||||
|
out[i] = file.readAll()
|
||||||
|
file.close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
local function format(scandata)
|
||||||
|
local format_data = {
|
||||||
|
files = {},
|
||||||
|
dirs = {}
|
||||||
|
}
|
||||||
|
local function scan_format(dir,data)
|
||||||
|
if type(data) == "table" then
|
||||||
|
local has_scanned = false
|
||||||
|
for k,v in pairs(data) do
|
||||||
|
has_scanned = true
|
||||||
|
scan_format(fs.combine(dir,k),v)
|
||||||
|
end
|
||||||
|
if not has_scanned then
|
||||||
|
format_data.dirs[#format_data.dirs+1] = dir
|
||||||
|
end
|
||||||
|
else
|
||||||
|
format_data.files[#format_data.files+1] = dir
|
||||||
|
end
|
||||||
|
end
|
||||||
|
scan_format("/",scandata)
|
||||||
|
return format_data
|
||||||
|
end
|
||||||
|
local textdata = textutils.serialise(format(scan("/")))
|
||||||
|
local firstpart = [[local expect = require "cc.expect".expect
|
||||||
|
local base_url = "https://git.cadencoaster.com/Ruffles/smithy-printer/raw/branch/main/"
|
||||||
|
local function download_to(path)
|
||||||
|
expect(2, path, "string")
|
||||||
|
term.write(path)
|
||||||
|
if not http.checkURL(base_url..path) then error("URL is not valid" ,2) end
|
||||||
|
local data = http.get(base_url..path).readAll()
|
||||||
|
fs.makeDir(fs.getDir(path))
|
||||||
|
local file = fs.open(path,"w")
|
||||||
|
if not file then error("Failed to open file", 2) end
|
||||||
|
file.write(data)
|
||||||
|
file.close()
|
||||||
|
print(" OK")
|
||||||
|
end
|
||||||
|
|
||||||
|
local filesystem = ]]
|
||||||
|
local secondpart = [[
|
||||||
|
for _,i in ipairs(filesystem.dirs) do
|
||||||
|
print("making dir",i)
|
||||||
|
fs.makeDir(i)
|
||||||
|
end
|
||||||
|
for _,i in ipairs(filesystem.files) do
|
||||||
|
download_to(i)
|
||||||
|
end
|
||||||
|
]]
|
||||||
|
local outfile = fs.open("install.lua","w")
|
||||||
|
outfile.write(firstpart..textdata..secondpart)
|
||||||
|
outfile.close()
|
||||||
Reference in New Issue
Block a user