Advertisement
veeir

installer code for dawn - an OS kernel with a filesystem i do it to install

Jul 23rd, 2023
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. --dawn installer
  2.  
  3. local handle
  4.  
  5. local rfs = {}
  6. local files = {}
  7.  
  8. local fshandle = assert(http.get("https://raw.githubusercontent.com/XDuskAshes/dawn/idev/install/fs"))
  9. repeat
  10. local a = fshandle.readLine()
  11. table.insert(rfs,a)
  12. until a == nil
  13. fshandle.close()
  14.  
  15. local fihandle = assert(http.get("https://raw.githubusercontent.com/XDuskAshes/dawn/idev/install/files"))
  16. repeat
  17. local a = fihandle.readLine()
  18. table.insert(files,a)
  19. until a == nil
  20. fihandle.close()
  21.  
  22. local function e(s)
  23. return s == nil or s == ""
  24. end
  25.  
  26. term.clear()
  27. term.setCursorPos(1,1)
  28. print("This installer will install the DAWN kernel on your system.")
  29. print("")
  30. print("The following is some quick setup for the main user account.")
  31.  
  32. print("Username:")
  33. write("> ")
  34. local user = read()
  35. if user == "root" then
  36. printError("Username cannot be 'root'. Defaulting to piggle")
  37. user = "piggle"
  38. elseif e(user) then
  39. printError("Username cannot be nil or ''. Defaulting to piggle")
  40. user = "piggle"
  41. end
  42.  
  43. print("Password:")
  44. write("> ")
  45. local password = read()
  46. if e(password) then
  47. password = "1234"
  48. printError("Password cannot be empty. (DEFAULT: 1234)")
  49. end
  50.  
  51. print("Add a home folder? (y/n (y is default)):")
  52. write("> ")
  53. local home = read()
  54. if home == "y" then
  55. home = true
  56. elseif home == "n" then
  57. home = false
  58. else
  59. home = true
  60. end
  61.  
  62. print("Should user be sudo? (y/n (y is default)):")
  63. write("> ")
  64. local sudo = read()
  65. if sudo == "y" then
  66. sudo = true
  67. elseif sudo == "n" then
  68. sudo = false
  69. else
  70. sudo = true
  71. end
  72.  
  73. print("Please note that as of now, this installer works with 'idev' branch only.")
  74. write("MAKE: basefs...")
  75. for k,v in pairs(rfs) do
  76. fs.makeDir(v)
  77. sleep(0.001)
  78. end
  79. print("done")
  80. write("MAKE: core...")
  81. for k,v in pairs(files) do
  82. shell.run("fg wget https://raw.githubusercontent.com/XDuskAshes/dawn/idev/"..v,v)
  83. sleep(0.01)
  84. print("DONE:",v)
  85. end
  86. print("done")
  87. print("Writing user data of "..user.." to /etc/passwd")
  88. local handle = fs.open("/etc/passwd","a")
  89. handle.write(user..":"..password..":1:")
  90. if home == true then
  91. fs.makeDir("/home/"..user)
  92. handle.write("/home/"..user..":")
  93. else
  94. handle.write("nil:")
  95. end
  96. handle.write("/usr/bin/dash.lua\n")
  97. handle.close()
  98. print("done")
  99. if sudo == true then
  100. print("Writing "..user.." to /etc/sudoers")
  101. local handle = fs.open("/etc/sudoers","a")
  102. handle.writeLine(user)
  103. handle.close()
  104. end
  105. print("Install complete. Rebooting in 3 seconds.")
  106. sleep(3)
  107. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement