Advertisement
sanovskiy

san-get

Jun 1st, 2015
2,595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. args = {...}
  2. command = args[1]
  3. args[2] = args[2] or "san-get"
  4. programs = {}
  5. programs["san-bb"] = "cc/san-bb.lua"
  6. programs["san-get"] = "cc/san-get.lua"
  7.  
  8. if not(fs.exists("san-bb")) then
  9.   print("Initial install...")
  10.   shell.run("pastebin","get gK3LCMmC san-bb")
  11. end
  12. function exec(cmd,params)
  13.   shell.run(cmd,params)
  14. end
  15. function update(program,url)
  16.   print("Removing old version of "..program)
  17.   exec("rm",program)
  18.   install(program,url)
  19. end
  20. function install(program,url)
  21.   print("Installing "..program)
  22.   exec("san-bb","get "..url.." "..program)
  23. end
  24. if command=="update" then
  25.   if programs[args[2]] ~= nil then
  26.     update(args[2],programs[args[2]])
  27.   else
  28.     error("Program "..args[2].." not found in repo")
  29.   end
  30. elseif command=="install" then
  31.   if programs[args[2]] ~= nil then
  32.     if fs.exists(args[2]) then
  33.       update(args[2],programs[args[2]])
  34.     else
  35.       install(args[2],programs[args[2]])
  36.     end
  37.   else
  38.     error("Program "..args[2].." not found in repo")
  39.   end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement