Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isFirstTime()
- if not fs.exists("/.complete") then
- return true
- else
- return false
- end
- end
- function completeSetup()
- file = fs.open("/.complete", "w")
- file.write("true")
- file.close()
- end
- local rdirs = {
- "/router",
- "/router/encryption"
- }
- term.clear()
- term.setCursorPos(1,1)
- if isFirstTime() then
- for _,dir in ipairs(rdirs) do
- fs.makeDir(dir)
- end
- local olddir = shell.dir()
- shell.setDir("/router/encryption")
- shell.run("pastebin get 6UV4qfNF sha256")
- shell.setDir(olddir)
- os.loadAPI("/router/encryption/sha256")
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome to Wi-Fi Setup!")
- print()
- term.write("AP: ")
- ap = read()
- term.write("Pass: ")
- pass = read("*")
- print()
- print("Processing...")
- local salt = "stuff"
- local hash = sha256.pbkdf2(pass, salt, 100):toHex()
- file = fs.open(fs.combine("/router/", "pass"), "w")
- file.write(hash)
- file.close()
- file = fs.open(fs.combine("/router/", "ap"), "w")
- file.write(ap)
- file.close()
- print()
- print("Would you like to have a sign-in screen? (Y/N)")
- result = read()
- if result == "Y" or result == "y" then
- term.write("User: ")
- user = read()
- term.write("Pass: ")
- pass = read()
- file = fs.open(fs.combine("/router/", "signin"), "w")
- file.write("function allowInternet()")
- file.write('rednet.broadcast("allowinternet")')
- file.write("term.clear()")
- file.write("term.setCursorPos(1,1)")
- file.write("end")
- file.write('file = fs.open(fs.combine("/router/", "ap"), "w")')
- file.write("local ap = file.readAll()")
- file.write('file.close()')
- completeSetup()
- os.reboot()
- elseif result == "N" or result == "n" then
- completeSetup()
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement