Advertisement
DrBurlao

BurlaOS installer

May 28th, 2023 (edited)
1,621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | Gaming | 0 0
  1. -- GitHub repository URL
  2. local repoUrl = "https://api.github.com/repos/DrBurlao/BurlaOSlast/contents"
  3.  
  4. -- Download file using wget
  5. local function downloadFile(url, destination)
  6. shell.run("wget", url, destination)
  7. end
  8.  
  9. -- Download directory and its contents recursively
  10. local function downloadDirectory(url, destination)
  11. shell.run("mkdir", destination)
  12. shell.run("cd", destination)
  13.  
  14. local listing = http.get(url)
  15. local content = listing.readAll()
  16. listing.close()
  17.  
  18. local files = textutils.unserializeJSON(content)
  19.  
  20. for _, file in ipairs(files) do
  21. if file.type == "file" then
  22. downloadFile(file.download_url, file.name)
  23. elseif file.type == "dir" then
  24. downloadDirectory(file.url, file.name)
  25. end
  26. end
  27.  
  28. shell.run("cd", "..")
  29. end
  30.  
  31. -- Get repository name from URL
  32. local function getRepositoryName(url)
  33. local _, _, repositoryName = string.find(url, "https://github.com/(.-)/")
  34. return repositoryName
  35. end
  36.  
  37. -- Delete existing files in the repository
  38. local function deleteExistingFiles(repositoryName)
  39. shell.run("rm", "-rf", repositoryName)
  40. end
  41.  
  42. -- Display ASCII art stored in ascii_art.txt
  43. local function displayASCIIArt()
  44. local asciiFile = fs.open("/user/BurlaOS/ascii_art.txt", "r")
  45. if asciiFile then
  46. term.clear()
  47. term.setCursorPos(1, 1)
  48. print(asciiFile.readAll())
  49. asciiFile.close()
  50. sleep(5)
  51. term.clear()
  52. term.setCursorPos(1, 1)
  53. end
  54. end
  55.  
  56. -- Start repository download
  57. print("Welcome to the BurlaOS Installation Program")
  58. print("-------------------------------------------")
  59.  
  60. -- Prompt user for confirmation
  61. print("This program will install BurlaOS on your computer.")
  62. print("Note: All existing files will be deleted.")
  63. print("Do you want to continue? (y/n)")
  64. local confirm = read()
  65.  
  66. if confirm == "y" or confirm == "Y" then
  67. -- Delete existing files
  68. local repositoryName = getRepositoryName(repoUrl)
  69. deleteExistingFiles(repositoryName)
  70.  
  71. -- Start download
  72. print("Downloading BurlaOS...")
  73. downloadDirectory(repoUrl, repositoryName)
  74. print("BurlaOS installation completed!")
  75.  
  76. -- Display ASCII art
  77. displayASCIIArt()
  78. else
  79. print("BurlaOS installation canceled. Exiting program.")
  80. end
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement