Advertisement
alexhorner

Installer/Updater

Jul 1st, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.91 KB | None | 0 0
  1. --Quartz OS Installer/Updater
  2.  
  3. print("\nWould you like to update this program to allow for new files from the most recent update?\n\nChoose no if this has been updated just a moment ago.\n\nChoose yes if this is a new install. [Y/N]")
  4.  
  5. while true do
  6.     evt, key, held = os.pullEvent("key")
  7.     if key == 21 then
  8.         fs.delete("/system/updater.lua")
  9.         shell.run("pastebin get iUuXr9je /system/updater.lua")
  10.         print("\nIf this is a new install, please now run '/system/updater.lua' and choose no at the next prompt.\n\nIf not please now run 'qupdate'")
  11.         continue = false
  12.         break
  13.     elseif key == 49 then
  14.         continue = true
  15.         break
  16.     end
  17. end
  18.  
  19. pastes = {"J9n73fsB", "H3erkhRc", "JS7FsH1F", "CJjXEKWx", "0YXPahu4"}
  20. locations = {"/startup.lua", "/system/drivers/audio.lua", "/system/drivers/display.lua", "/system/audioalerts.lua", "/system/compatibility/compat.lua"}
  21. names = {"Startup", "Audio Driver", "Display Driver", "Audio Alert Library", "Compatibility Layer"}
  22. optional = {false, false, false, false, false}
  23.  
  24. function install(id, check, updating)
  25.     if check and fs.exists(locations[id]) then
  26.         fs.delete(locations[id])
  27.         update = true
  28.     elseif updating then
  29.         update = true
  30.     else
  31.         update = false
  32.     end
  33.    
  34.     shell.run("pastebin get "..pastes[id].." "..locations[id])
  35.  
  36.     if update then
  37.         print("Updated "..names[id])
  38.     else
  39.         print("Installed "..names[id])
  40.     end
  41.     print()
  42. end
  43.  
  44. function ask(id)
  45.     if fs.exists(locations[id]) then
  46.         fs.delete(locations[id])
  47.         install(id, false, true)
  48.         return
  49.     end
  50.    
  51.     print()
  52.     print("Would you like to install "..names[id].."? [Y/N]")
  53.     while true do
  54.         evt, key, held = os.pullEvent("key")
  55.         if key == 21 then
  56.             install(id, false, false)
  57.             return
  58.         elseif key == 49 then
  59.             return
  60.         end
  61.     end
  62. end
  63.    
  64. if continue then
  65.     for id = 1,#pastes do
  66.         if not optional[id] then
  67.             install(id, true, false)
  68.         else
  69.             ask(id)
  70.         end
  71.     end
  72.     print("IT IS RECOMMENDED YOU NOW REBOOT!")
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement