Guest User

Untitled

a guest
May 2nd, 2019
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. local computer = require("computer")
  2. local fs = require("filesystem")
  3. local kb = require("keyboard")
  4. local event = require("event")
  5. local shell = require("shell")
  6. local term = require("term")
  7.  
  8. local running = true
  9.  
  10. local function greeting()
  11. term.clear()
  12. term.setCursor(1,1)
  13. print("Welcome to the SecureOS installer!")
  14. print("This installer will help guide you through setting up and installing SecureOS.")
  15. print("Press any key to continue.")
  16. local event = event.pull("key_down")
  17. if event and not kb.isControlDown() then
  18. term.clear()
  19. term.setCursor(1,1)
  20. end
  21. end
  22.  
  23. local function downLoad()
  24.  
  25. if not fs.exists("/tmp/.root") then
  26. r = io.open("/tmp/.root", "w")
  27. r:write("true")
  28. r:close()
  29. end
  30.  
  31. if not fs.exists("/tmp/.install") then
  32. input = io.open("/tmp/.install", "w")
  33. input:write(os.date())
  34. input:close()
  35. end
  36.  
  37. if not fs.exists("/etc/update.cfg") then
  38. c = io.open("/etc/update.cfg", "w")
  39. c:write("release")
  40. c:close()
  41. end
  42.  
  43. term.write("Please wait while the files are downloaded and installed.")
  44. os.sleep(1)
  45. term.setCursor(1,2)
  46.  
  47. shell.execute("wget -q https://raw.githubusercontent.com/Shuudoushi/SecureOS/release/sbin/update.lua /sbin/update.lua \n")
  48. shell.execute("/sbin/update.lua")
  49. end
  50.  
  51. local function userInfo()
  52. term.clear()
  53. term.setCursor(1,1)
  54. term.write("Please enter a username and password.")
  55. term.setCursor(1,2)
  56. term.write("Username: ")
  57. username = string.lower(io.read())
  58. term.setCursor(1,3)
  59. term.write("Password: ")
  60. password = string.gsub(term.read(nil, nil, nil, ""), "\n", "")
  61.  
  62. require("auth").addUser(username, password, true)
  63.  
  64. if not fs.exists("/home/" .. username .. "/") then
  65. fs.makeDirectory("/home/" .. username .. "/")
  66. fs.makeDirectory("/home/" .. username .. "/bin/")
  67. fs.makeDirectory("/home/" .. username .. "/lib/")
  68. fs.makeDirectory("/home/" .. username .. "/var/")
  69. end
  70.  
  71. term.clear()
  72. term.setCursor(1,1)
  73. term.write("Would you like to restart now? [Y/n]")
  74. term.setCursor(1,2)
  75. input = string.lower(io.read())
  76.  
  77. if input == "y" or input == "yes" then
  78. computer.shutdown(true)
  79. elseif input == "n" or input == "no" then
  80. io.write("Returning to shell.")
  81. os.sleep(1.5)
  82. term.clear()
  83. term.setCursor(1,1)
  84. running = false
  85. end
  86. end
  87.  
  88. while running do
  89. greeting()
  90. downLoad()
  91. userInfo()
  92. end
Add Comment
Please, Sign In to add comment