Advertisement
DOGGYWOOF

Doggy OS Package Manager Upadater

May 27th, 2024 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. -- Define a function to delete a file if it exists
  2. local function deleteFile(path)
  3. if fs.exists(path) then
  4. fs.delete(path)
  5. print("Deleted existing file: " .. path)
  6. end
  7. end
  8.  
  9. -- Define a function to download a file from Pastebin
  10. local function downloadFile(pastebinCode, path)
  11. local response = http.get("https://pastebin.com/raw/" .. pastebinCode)
  12. if response then
  13. local content = response.readAll()
  14. response.close()
  15.  
  16. local file = fs.open(path, "w")
  17. file.write(content)
  18. file.close()
  19.  
  20. print("Downloaded " .. path)
  21. else
  22. print("Failed to download " .. pastebinCode)
  23. end
  24. end
  25.  
  26. -- Define file paths and Pastebin codes
  27. local files = {
  28. {code = "3vvyfD4Y", path = "/disk/os/programs"},
  29. {code = "p6TqHfWw", path = "/disk/packages/package-editor"},
  30. {code = "LYPfg5JZ", path = "/disk/packages/package-remover"},
  31. {code = "5hSF8Rda", path = "/disk/packages/package-installer"}
  32. }
  33.  
  34. -- Delete existing files and download new ones
  35. for _, file in ipairs(files) do
  36. deleteFile(file.path)
  37. downloadFile(file.code, file.path)
  38. end
  39.  
  40. -- Display update complete message and wait for user input
  41. print("Update Complete. Press Enter to continue...")
  42. read()
  43.  
  44. -- Run the specified program
  45. shell.run("/disk/os/gui")
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement