Advertisement
Guest User

sos

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