Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("This is the installer for Xelo's storage system.")
- if (fs.exists("/storage")) then
- error("The path /storage is already in use. Please rename or remove this folder to continue the installation.")
- end
- if (fs.exists("/startup") or fs.exists("/startup.lua")) then
- error("The filename startup.lua is already used. Please rename or remove this file to continue the installation.")
- end
- print("Please enter the installer code:")
- term.write("> ")
- local code = read()
- print("Verifying code...")
- local baseURL = "http://bambootown.online:25556"
- local verifyPage = http.get(baseURL .. "/verifyCode/" .. code)
- assert(verifyPage, "Failed to reach the webserver!")
- local verifyRaw = verifyPage.readAll()
- verifyPage.close()
- assert(verifyRaw == "true", "Invalid code entered!")
- print("Succesfully verified code!")
- local codeFile = fs.open("/storage/code.txt", "w")
- codeFile.write(code)
- codeFile.close()
- local mainPage = http.get(baseURL .. "/filesServer.txt")
- assert(mainPage, "Failed to reach the webserver!")
- local filesRaw = mainPage.readAll()
- mainPage.close()
- print("Files to read:\n" .. filesRaw)
- fs.makeDir("/storage")
- print("Installing...")
- for name in filesRaw:gmatch("[^%s]+") do
- local page = http.get(baseURL .. "/getServer/" .. code .. "/" .. name)
- assert(page, "Failed to reach the webserver!")
- local fileRaw = page.readAll()
- page.close()
- local file = fs.open("/storage/" .. name, "w")
- file.write(fileRaw)
- file.close()
- end
- local startupFile = fs.open("/startup.lua", "w")
- startupFile.write("shell.run(\"/storage/storage.lua\")")
- startupFile.close()
- print("Success: downloaded all files!")
- print("Rebooting...")
- sleep(3)
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement