mirror of
https://github.com/Kiritow/OpenComputerScripts.git
synced 2024-03-22 13:10:46 +08:00
Grab v2.3.1-alpha
Programs provider proxy, repo, branch.
This commit is contained in:
parent
b285e6e5a2
commit
a18770896f
35
grab.lua
35
grab.lua
|
@ -8,7 +8,7 @@ local serialization=require('serialization')
|
||||||
local event=require('event')
|
local event=require('event')
|
||||||
local args,options=shell.parse(...)
|
local args,options=shell.parse(...)
|
||||||
|
|
||||||
local grab_version="Grab v2.3-alpha"
|
local grab_version="Grab v2.3.1-alpha"
|
||||||
|
|
||||||
local valid_options={
|
local valid_options={
|
||||||
["cn"]=true, ["help"]=true, ["version"]=true, ["proxy"]=true, ["skip_install"]=true
|
["cn"]=true, ["help"]=true, ["version"]=true, ["proxy"]=true, ["skip_install"]=true
|
||||||
|
@ -114,15 +114,12 @@ if(not options["proxy"]) then
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local ok,err=pcall(function()
|
local ok,err=pcall(function()
|
||||||
local f=io.open(options["proxy"],"r")
|
local fn,xerr=loadfile(options["proxy"])
|
||||||
if(f==nil) then error("Proxy file not found") end
|
if(not fn) then error(xerr)
|
||||||
local src=f:read("a")
|
else UrlGenerator=fn() end
|
||||||
f:close()
|
|
||||||
local fn=load(src)
|
|
||||||
UrlGenerator=fn()
|
|
||||||
end)
|
end)
|
||||||
if(not ok) then
|
if(not ok) then
|
||||||
print("Proxy file error: " .. err)
|
print("Unable to load proxy file: " .. err)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -258,6 +255,8 @@ if(args[1]=="add") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print("[WARN] Adding unofficial program providers may have security issues.")
|
||||||
|
|
||||||
for i=2,#args,1 do
|
for i=2,#args,1 do
|
||||||
local url=string.match(args[i],"^http[s]?://%S+")
|
local url=string.match(args[i],"^http[s]?://%S+")
|
||||||
if(url==nil) then
|
if(url==nil) then
|
||||||
|
@ -384,7 +383,25 @@ if(args[1]=="install") then
|
||||||
end
|
end
|
||||||
|
|
||||||
io.write("[" .. id_installing .. "/" .. count_files .. "] Downloading " .. toDownload .. " for " .. this_lib .. "... ")
|
io.write("[" .. id_installing .. "/" .. count_files .. "] Downloading " .. toDownload .. " for " .. this_lib .. "... ")
|
||||||
local ok,result,code=download(UrlGenerator("Kiritow/OpenComputerScripts","master",toDownload))
|
local this_url
|
||||||
|
if(db[this_lib].proxy) then
|
||||||
|
this_url=string.gsub(
|
||||||
|
string.gsub(
|
||||||
|
string.gsub(
|
||||||
|
db[this_lib].proxy,
|
||||||
|
"__repo__",
|
||||||
|
db[this_lib].repo or "Kiritow/OpenComputerScripts"
|
||||||
|
),
|
||||||
|
"__branch__",
|
||||||
|
db[this_lib].branch or "master"
|
||||||
|
),
|
||||||
|
"__file__",
|
||||||
|
toDownload
|
||||||
|
)
|
||||||
|
else
|
||||||
|
this_url=UrlGenerator(db[this_lib].repo or "Kiritow/OpenComputerScripts",db[this_lib].branch or "master",toDownload)
|
||||||
|
end
|
||||||
|
local ok,result,code=download(this_url)
|
||||||
if(not ok) then
|
if(not ok) then
|
||||||
print("[Download Failed] " .. result)
|
print("[Download Failed] " .. result)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user