Sirshark10

run

May 20th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. local args = {...}
  2. _G.os.pullEvent = function(...)
  3. local ret = {kernel.yield(...)}
  4. if string.lower(ret[1]) == "terminate" then
  5. error("Terminated", 0)
  6. end
  7. return table.unpack(ret)
  8. end
  9. _G.fs.isReadOnly = function(...) return not kernel.hasread(...) end
  10. local cont
  11. local rPath
  12. local CC = kernel.getpwnam("CC").pw_uid
  13. local tDir
  14. if fs.exists("/etc/os-release") then
  15. local file = fs.open("/etc/os-release","r")
  16. cont = file.readAll()
  17. file.close()
  18. else
  19. cont = " N/R "
  20. end
  21. cont = string.sub(cont,0,6)
  22. _G.version = cont
  23. _G.os.version = function()
  24. return "CraftOS | Vorbani: ".._G.version
  25. end
  26.  
  27. if not args[1] then
  28. return printError("Usage: launch <target dir> [rom path]")
  29. else
  30. tDir = args[1]
  31. end
  32. if not args[2] then
  33. rPath = "/CraftOS/rom"
  34. else
  35. rPath = args[2]
  36. end
  37.  
  38. _G.os.run = function(env,path,...)
  39. if fs.exists(path) then
  40. local file = fs.open(path,"r")
  41. local cont = file.readAll()
  42. file.close()
  43. return load(cont,path,nil,env)(...)
  44. else
  45. return printError("Please input a valid path")
  46. end
  47. end
  48.  
  49. if not fs.exists(tDir.."/dev") then
  50. fs.makeDir(tDir.."/dev")
  51. end
  52. kernel.mount("dattach",tDir.."/dev")
  53. if not fs.exists(tDir.."/proc") then
  54. fs.makeDir(tDir.."/proc")
  55. end
  56. kernel.mount("proc",tDir.."/proc")
  57. if not fs.exists(tDir.."/rom") then
  58. fs.makeDir(tDir.."/rom")
  59. end
  60. kernel.mount(rPath,tDir.."/rom",true)
  61. term.clear()
  62. term.setCursorPos(1,1)
  63. kernel.chroot(tDir)
  64. kernel.setuid(CC)
  65. os.run({},"/rom/programs/shell")
Advertisement
Add Comment
Please, Sign In to add comment