Lyqyd

LyqydOS Installer

Oct 28th, 2012
22,282
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     if not fs.exists("/usr/bin/packman") then
  68.         local response = http and http.get("https://raw.github.com/lyqyd/cc-packman/master/packman")
  69.         if response then
  70.             if not fs.exists("/usr/bin") then fs.makeDir("/usr/bin") end
  71.             local handle = io.open("/usr/bin/packman", "w")
  72.             if handle then
  73.                 handle:write(response.readAll())
  74.                 handle:close()
  75.             else
  76.                 error("Could not write /usr/bin/packman")
  77.             end
  78.             response.close()
  79.         else
  80.             error("Could not fetch packman")
  81.         end
  82.         shell.run("/usr/bin/packman bootstrap")
  83.     else
  84.         shell.run("/usr/bin/packman fetch")
  85.     end
  86.     shell.run("/usr/bin/packman force install lyqydos")
  87. end
RAW Paste Data