Advertisement
Xelostar

StorageSystemClientInstaller

Jan 8th, 2020
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1.  
  2. print("This is the installer for Xelo's storage system (client).")
  3. if (fs.exists("/storage")) then
  4.     error("The path /storage is already in use. Please rename or remove this folder to continue the installation.")
  5. end
  6. if (fs.exists("/startup") or fs.exists("/startup.lua")) then
  7.     error("The filename startup.lua is already used. Please rename or remove this file to continue the installation.")
  8. end
  9.  
  10. local baseURL = "http://bambootown.online:25556"
  11.  
  12. local mainPage = http.get(baseURL .. "/filesClient.txt")
  13. assert(mainPage, "Failed to reach the webserver!")
  14. local filesRaw = mainPage.readAll()
  15. mainPage.close()
  16.  
  17. print("Files to read:\n" .. filesRaw)
  18.  
  19. fs.makeDir("/storage")
  20.  
  21. print("Installing...")
  22. for name in filesRaw:gmatch("[^%s]+") do
  23.     local page = http.get(baseURL .. "/getClient/" .. name)
  24.     assert(page, "Failed to reach the webserver!")
  25.     local fileRaw = page.readAll()
  26.     page.close()
  27.  
  28.     local file = fs.open("/storage/" .. name, "w")
  29.     file.write(fileRaw)
  30.     file.close()
  31. end
  32.  
  33. local startupFile = fs.open("/startup.lua", "w")
  34. startupFile.write("shell.run(\"/storage/run.lua\")")
  35. startupFile.close()
  36.  
  37. print("Success: downloaded all files!")
  38.  
  39. print("Rebooting...")
  40. sleep(3)
  41. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement