Sxw1212

CCBox

Mar 2nd, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. local args={...}
  2. if not #args==1 then
  3. error("Usage: ccbox [folder]",0)
  4. end
  5.  
  6. --Download Required API's
  7. print("Updating...")
  8. local apis={}
  9. apis.redirect="https://raw.github.com/Sxw1212/ccprograms/master/gopher/redirect"
  10. apis.goroutine="https://raw.github.com/Sxw1212/ccprograms/master/gopher/goroutine"
  11. apis.chrootapi="https://raw.github.com/Sxw1212/ccprograms/master/chrootapi"
  12. if not fs.isDir("/.ccbox") then
  13. fs.delete("/.ccbox")
  14. fs.makeDir("/.ccbox")
  15. end
  16. for k,v in pairs(apis) do
  17. local req=http.get(v)
  18. if req then
  19. fs.delete("/.ccbox/"..k)
  20. local fh=fs.open("/.ccbox/"..k,"w")
  21. fh.write(req.readAll())
  22. fh.close()
  23. os.loadAPI("/.ccbox/"..k)
  24. else
  25. error("Updating failed for "..k, 0)
  26. end
  27. end
  28. local updateurl="https://raw.github.com/Sxw1212/ccprograms/master/ccboxupd"
  29. local req=http.get(updateurl)
  30. if req then
  31. fs.delete("/.ccbox/ccboxupd")
  32. local fh=fs.open("/.ccbox/ccboxupd","w")
  33. fh.write(req.readAll())
  34. fh.close()
  35. else
  36. error("Updating failed for ccboxupd", 0)
  37. end
  38. print("Lauching...")
  39. vmpath=args[1]
  40. if shell then
  41. args[1]=shell.resolve(args[1])
  42. end
  43. os.run({}, "/.ccbox/ccboxupd", unpack(args))
  44. term.setBackgroundColor(colors.black)
  45. term.setTextColor(colors.white)
  46. print("CCBox has exited")
Advertisement
Add Comment
Please, Sign In to add comment