Ocawesome101

OC-CC-Kernel Installer

Dec 11th, 2019 (edited)
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.21 KB | None | 0 0
  1. -- The oc-cc-kernel installer --
  2. -- GitGet is made by Apemanzilla --
  3.  
  4. local user = ""
  5. local password = ":(){:|:&}"
  6. local confirmedPassword = "HSA*(*)J" -- Placeholder
  7. local gitget = "W5ZkVYSi"
  8. local baseURL = "https://raw.githubusercontent.com/"
  9. local ocefi = baseURL .. "ocawesome101/ocbios/master/uefi.lua"
  10.  
  11. local ccbios = false
  12. if os.version():sub(1,7) == "CC-BIOS" then ccbios = true end
  13.  
  14. local filesToRemove = {"json","README.md","DOCS.md"}
  15.  
  16. local function exec(code, arg1, arg2)
  17.   local d = http.get("https://pastebin.com/raw/" .. code)
  18.   local e = loadstring(d.readAll())
  19.   d.close()
  20.   local M = {}
  21.   M.shell = {}
  22.   M.shell.resolve = function(path)
  23.     return path
  24.   end
  25.   M.http = http
  26.   M.os = os
  27.   M.fs = fs
  28.   M.string = string
  29.   M.table = table
  30.   M.print = print
  31.   setmetatable(M, {__index = _G})
  32.   setfenv(e, M)
  33.   e(arg1, arg2)
  34. end
  35.  
  36. print("Welcome to the OC-CC-Kernel installer.")
  37. sleep(0.2)
  38. write("Install OC-CC-Kernel to the main hard drive? [y/n]: ")
  39. local inst = read():lower()
  40.  
  41. if inst == "y" then
  42.   print("The base system will now be downloaded and set up.")
  43.   exec(gitget, "ocawesome101", "oc-cc-kernel")
  44.   for i=1, #filesToRemove, 1 do
  45.     if fs.exists(filesToRemove[i]) then
  46.       fs.delete(filesToRemove[i])
  47.     end
  48.   end
  49.   if not ccbios then
  50.     print("CC-BIOS not detected-- downloading EFI system required to boot oc-cc-kernel")
  51.     shell.run("wget", ocefi, "startup.lua")
  52.   else
  53.     print("CC-BIOS detected-- skipping download of startup.lua")
  54.   end
  55.   print("This installer will now perform some basic setup.")
  56.   print("Usernames and passwords cannot contain spaces.")
  57.   while true do
  58.     local continue = false
  59.     write("Please input a username (i.e. john): ")
  60.     user = read()
  61.     for i=1, #user, 1 do
  62.       if user:sub(i,i) == " " then
  63.         continue = true
  64.       end
  65.     end
  66.     if not continue then
  67.       break
  68.     end
  69.     print("Username cannot contain spaces")
  70.   end
  71.  
  72.   while true do
  73.     local continue = false
  74.     write("Please input a password: ")
  75.     password = read("*")
  76.     write("Confirm password: ")
  77.     confirmedPassword = read("*")
  78.     if password == confirmedPassword then
  79.       for i=1, #password, 1 do
  80.         if password:sub(i,i) == " " then
  81.           continue = true
  82.         end
  83.       end
  84.     else
  85.       print("Passwords do not match")
  86.       continue = true
  87.     end
  88.    
  89.     if not continue then
  90.       break
  91.     end
  92.    
  93.     print("Password cannot contain spaces")
  94.   end
  95.  
  96.   local userdata = "return {\n  \"" .. user .. "\"\n}"
  97.   local pwddata  = "return {\n  \"" .. password .. "\"\n}"
  98.  
  99.   print("Saving username and password; creating user")
  100.   local h = fs.open("/etc/userdata/users.lua", "w")
  101.   h.write(userdata)
  102.   h.close()
  103.   local h = fs.open("/etc/userdata/passwords.lua", "w")
  104.   h.write(pwddata)
  105.   h.close()
  106.  
  107.   fs.makeDir("/home/" .. user)
  108.   fs.makeDir("/root")
  109.   print("Now that a user has been set up, your system can be restarted.")
  110.   write("Restart now? [y/n]: ")
  111.   if read() == ("y" or "Y") then
  112.     print("Restarting.")
  113.     sleep(0.2)
  114.     os.reboot()
  115.   else
  116.     print("Exiting.")
  117.     os.sleep(0.2)
  118.   end
  119. else
  120.   print("Not installing OC-CC-Kernel. Have a nice day.")
  121.   sleep(1)
  122.   os.reboot()
  123. end
Add Comment
Please, Sign In to add comment