Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CC-OS installer to accompany CC-BIOS --
- shell = {}
- function shell.resolve(path) -- Make GitGet work!
- return path
- end
- local function find(sStr, tChars)
- for i=1, #tChars, 1 do
- if sStr:find(tChars[i], 1, true) then
- return true
- end
- end
- return false
- end
- local function num(str)
- local rtn = {}
- for i=1, #str, 1 do
- table.insert(rtn, keys[str:sub(i,i)])
- print(str:sub(i,i), keys[str:sub(i,i)])
- end
- return rtn
- end
- local function encode(str)
- local rtn = ""
- local tNum = num(str)
- for i=1, #tNum, 1 do
- rtn = rtn .. tostring(bit32.arshift(tNum[i], i))
- if i < #tNum then
- rtn = rtn .. ":"
- end
- end
- return rtn
- end
- local function generateFile(uname, pwd)
- return "return {\n {\n username = " .. uname .. ",\n uid = 1,\n password = " .. pwd .. "\n }\n}"
- end
- local data = http.get("https://pastebin.com/raw/W5ZkVYSi")
- local exec = loadstring(data.readAll())
- data.close()
- exec("ocawesome101", "cc-os")
- term.clear()
- term.setCursorPos(1,1)
- print("CC-OS has been installed. There is now some basic setup to do.")
- local specialChars = {" ", "/", "?", ".", ",", "<", ">", "\"", "'", "|", "[", "]", "{", "}", "-", "_", "+", "=", "(", ")", "`", "~", "!", "@", "#", "$", "\%", "^", "&", "*"} -- Sorry
- local uname, passwd = "", ""
- while true do
- write("Enter a username: ")
- uname = read()
- if find(uname, specialChars) then
- printError("Usernames cannot contain special characters.")
- else
- break
- end
- end
- while true do
- write("Enter a password: ")
- passwd = read("*")
- if #passwd < 4 then
- break
- else
- print("Password must be four or more characters.")
- end
- end
- passwd = encode(passwd)
- local toWrite = generateFile(uname, passwd)
- print("The following operations will be performed:")
- print("Create /home/" .. uname)
- print("Store " .. toWrite .. " in /etc/passwd")
- write("Apply changes? [y/n]: ")
- local c = read()
- if c:lower() == "n" then
- print("I hope you know the root password!")
- sleep(1)
- os.reboot()
- end
- fs.makeDir("/etc")
- fs.makeDir("/home/" .. uname)
- local handle = fs.open("/etc/passwd")
- handle.write(toWrite)
- handle.close()
- print("Done")
- sleep(2)
- os.reboot()
Add Comment
Please, Sign In to add comment