Advertisement
StateOfDream

Untitled

Apr 13th, 2021 (edited)
1,255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. local remoteUrl = "https://raw.githubusercontent.com/realGiB/pocketOS/main/"
  2.  
  3. local next = "/System/loadOS"
  4. local files = {"startup", "/System/.version", "/System/autoupdater", "/System/loadOS"}
  5.  
  6. local remoteVersion = http.get(remoteUrl .. "System/.version")
  7. local localVersion = fs.open("System/.version", "r")
  8.  
  9. local rVersion = remoteVersion.readAll()
  10. -- Initialize at 0 for first-time installation, etc.
  11. local lVersion = 0
  12. if localVersion ~= nil then
  13.     lVersion = localVersion.readAll()
  14.     localVersion.close()
  15. end
  16.  
  17. if rVersion ~= lVersion then
  18.     print("Downloading Update...")
  19.     print("Your Verison: ", lVersion)
  20.     print("New Version: ", rVersion)
  21.     for k, file in pairs(files) do
  22.         print("Downloading... " .. file)
  23.         local currentFile = fs.open(file, "w")
  24.         local remoteFile = http.get(remoteUrl .. file)
  25.         if remoteFile ~= nil then
  26.             currentFile.write(remoteFile.readAll())
  27.             remoteFile.close()
  28.             print("Remote file doesn't exist!")
  29.         end
  30.         currentFile.close()
  31.  
  32.     end
  33. else
  34.     print("You're up to date!")
  35. end
  36. print('done')
  37. shell.run(next)
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement