Margresse404

updateTheUpdater

Jun 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. local versionNumber = 3.3
  2.  
  3. local args = {...}
  4.  
  5. if #args >= 1 then
  6. if args[1] == "setup" then
  7. --sane default window sizes
  8. local lyqwin = [[
  9. 1,1,9,4,false,rom/programs/reboot
  10. 1,1,9,4,false,rom/programs/shutdown
  11. 1,1,19,9,true,rom/programs/color/paint
  12. 3,3,47,15,false,rom/programs/shell
  13. 2,2,47,15,false,rom/programs/lua
  14. ]]
  15. local lyqwinPocket = [[
  16. 1,1,9,4,false,rom/programs/reboot
  17. 1,1,9,4,false,rom/programs/shutdown
  18. 1,1,19,9,true,rom/programs/color/paint
  19. 1,3,26,16,false,rom/programs/shell
  20. 1,4,26,16,false,rom/programs/lua
  21. ]]
  22. if pocket then lyqwin = lyqwinPocket end
  23. if pack then
  24. pack.addFile("/LyqydOS/.lyqwin", lyqwin)
  25. else
  26. if not fs.exists("/LyqydOS/.lyqwin") then
  27. local handle = io.open("/LyqydOS/.lyqwin", "w")
  28. if handle then
  29. handle:write(lyqwin)
  30. handle:close()
  31. end
  32. end
  33. end
  34. print("Run LyqydOS on startup? (y/N)")
  35. term.write("> ")
  36. local input = io.read()
  37. if #input > 0 then
  38. input = string.lower(string.sub(input, 1, 1))
  39. if input == "y" then
  40. local handle
  41. if fs.exists("/startup") then
  42. handle = io.open("/startup", "a")
  43. else
  44. handle = io.open("/startup", "w")
  45. end
  46. if handle then
  47. handle:write([[shell.run("/LyqydOS/procman")]].."\n")
  48. handle:close()
  49. end
  50. end
  51. end
  52. elseif args[1] == "remove" then
  53. if pack then
  54. pack.removeFile("/LyqydOS/.config")
  55. pack.removeFile("/LyqydOS/.lyqrunhistory")
  56. pack.removeFile("/LyqydOS/.lyqshellrunhistory")
  57. pack.removeFile("/LyqydOS/.lyqwin")
  58. else
  59. if fs.exists("/LyqydOS/.config") then fs.delete("/LyqydOS/.config") end
  60. if fs.exists("/LyqydOS/.lyqrunhistory") then fs.delete("/LyqydOS/.lyqrunhistory") end
  61. if fs.exists("/LyqydOS/.lyqshellrunhistory") then fs.delete("/LyqydOS/.lyqshellrunhistory") end
  62. if fs.exists("/LyqydOS/.lyqwin") then fs.delete("/LyqydOS/.lyqwin") end
  63. end
  64. end
  65. else
  66. --get packman and use it.
  67.  
  68.  
  69. local otherHTTPs = {"https://raw.githubusercontent.com/MargreetH/windowTryout/master/automateUpdateDing.lua"}
  70. local otherpaths = {""}
  71. local fileName = {"refreshFiles"}
  72.  
  73. for i=1, #fileName, 1 do
  74.  
  75. local response = http and http.get(otherHTTPs[i])
  76. if response then
  77. local handle = io.open(otherpaths[i].."/"..fileName[i], "w")
  78. if handle then
  79. handle:write(response.readAll())
  80. handle:close()
  81. else
  82. error("Could not write ")
  83. end
  84. response.close()
  85. else
  86. error("Could not fetch file")
  87. end
  88.  
  89. end
  90.  
  91.  
  92.  
  93.  
  94. end
Advertisement
Add Comment
Please, Sign In to add comment