Advertisement
shadowkat1010

installer

May 5th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 KB | None | 0 0
  1. local filesystem = require "filesystem"
  2. local component = require "component"
  3. local process = require "process"
  4.  
  5. local bootloader = [[
  6. local proxy = ...
  7. local filesystem = require "filesystem"
  8. local component = require "component"
  9. local term = require "term"
  10.  
  11. local maxResX,maxResY = component.gpu.maxResolution()
  12.  
  13. if maxResX >= 80 and maxResY >= 25 then
  14.  component.gpu.setResolution(80,25)
  15. end
  16.  
  17. term.clear()
  18.  
  19. print("SKS-BOOT\a")
  20. for k,v in component.list() do
  21.  if v == "filesystem" then
  22.   if filesystem.proxy(k).getLabel() ~= nil then
  23.    print(k,filesystem.proxy(k).getLabel())
  24.   else
  25.    print(k)
  26.   end
  27.  end
  28. end
  29. print("\nBoot device:")
  30. local rPartPath = io.read()
  31. local partPath = rPartPath:sub(1,rPartPath:len()-1)
  32.  
  33. filesystem.umount("/")
  34. filesystem.mount(component.proxy(component.get(partPath)),"/")]]
  35.  
  36.  
  37. local revRunningFrom = process.running():reverse()
  38. local rFrFiSl = revRunningFrom:find("/")
  39. local runningFrom = process.running():sub(1,-rFrFiSl-1)
  40. print "SKS-OS installer"
  41. print("Running from: "..runningFrom)
  42. print "Install to:"
  43. local insLoc = io.read()
  44. print("Install to "..insLoc)
  45. print("Confirm Y/N")
  46. local conf = io.read():lower()
  47. if conf == "n" then
  48.  error "operation cancelled"
  49. end
  50.  
  51. print("Make directory: /bin")
  52. filesystem.makeDirectory(insLoc.."/bin")
  53. print("Make directory: /lib")
  54. filesystem.makeDirectory(insLoc.."/lib")
  55. print("Make directory: /usr")
  56. filesystem.makeDirectory(insLoc.."/usr")
  57. print("Make directory: /usr/man")
  58. filesystem.makeDirectory(insLoc.."/usr/man")
  59. print("Make directory: /etc")
  60. filesystem.makeDirectory(insLoc.."/etc")
  61. print("Make directory: /home")
  62. for f in filesystem.list("/bin") do
  63.  print(f)
  64.  filesystem.copy("/bin/"..f,insLoc.."/bin/"..f)
  65. end
  66.  
  67.  
  68. for f in filesystem.list("/lib") do
  69.  print(f)
  70.  filesystem.copy("/lib/"..f,insLoc.."/lib/"..f)
  71. end
  72.  
  73.  
  74. for f in filesystem.list("/usr/man") do
  75.  print(f)
  76.  filesystem.copy("/usr/man/"..f,insLoc.."/usr/man/"..f)
  77. end
  78.  
  79. local fObj = io.open(insLoc.."/autorun.lua","w")
  80. fObj:write(bootloader)
  81. fObj:close()
  82.  
  83. local filesystem = nil
  84. local component = nil
  85. local process = nil
  86. local insLoc = nil
  87. local bootloader = nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement