Advertisement
ferel

Untitled

Aug 29th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     filein = io.open("/tmp/.install", "w")
  33.       filein:write(os.date())
  34.         filein: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. pokemongotorussia = require("auth").addUser
  63.  
  64. pokemongotorussia(username, password, true)
  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