goldfiction

axiom os

Jul 21st, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.48 KB | None | 0 0
  1. local tArgs= {...}
  2. -- Installer properties
  3. local delete_files = false
  4. local skip_branch_select = false
  5. local reboot = false
  6. local format = false
  7.  
  8. local user = "nothjarnan"
  9. local branch = 1
  10.  
  11. -- Branches
  12. local branches = {
  13.   "master",
  14.   "experimental",
  15.   "hotfix",
  16. }
  17.  
  18. for k,v in ipairs(tArgs) do
  19.   if v == "-f" then
  20.     format = true
  21.   end
  22.   if v == "-r" then
  23.     reboot = true
  24.   end
  25.   if v == "-d" then
  26.     delete_files = true
  27.   end
  28.   for a,b in ipairs(branches) do
  29.     if v == b then
  30.       branch = b
  31.       skip_branch_select = true
  32.       print("Selected branch "..b)
  33.       break
  34.     end
  35.   end
  36. end
  37. if format then
  38.   term.setTextColor(colors.red)
  39.   print("WARNING")
  40.   term.setTextColor(colors.white)
  41.   print("Formatting your system *WILL* remove *EVERY* file from your computer, CONTINUE? (hold Y)")
  42.   while(true) do
  43.     local event, key, isHeld = os.pullEvent("key")
  44.     if isHeld then
  45.       if key == keys.y then
  46.         print("Formatting.. ")
  47.         local files = fs.list("/")
  48.         for k,v in ipairs(files) do
  49.           if v ~= "rom" and v ~= shell.getRunningProgram() then
  50.             print("-"..v)
  51.             fs.delete(v)
  52.             sleep(.1)
  53.             -- Wait a tiny bit to actually make it look like it's working.
  54.             -- This is actually a scientifically proven thing, people are more trustworthy of things that 'look' like
  55.             -- It's doing something, rather than something that actually does something. That's how ransomware works!
  56.           end
  57.         end
  58.         print("Format complete")
  59.         break
  60.       else
  61.         break
  62.       end
  63.     end
  64.   end
  65. end
  66.  
  67. local function formatFS()
  68.   local function mkdir(dir)
  69.     if not fs.exists(dir) then fs.makeDir(dir) end
  70.   end
  71.   if fs.exists("AxiomUI") then
  72.     for k, v in pairs(fs.list("AxiomUI")) do
  73.       if not fs.exists(v) then
  74.         fs.move("AxiomUI/"..v, v)
  75.         print("AxiomUI/"..v.." -> "..v)
  76.       else
  77.         print("AxiomUI/"..v.." -x>")
  78.       end
  79.     end
  80.     fs.delete("AxiomUI")
  81.     -- Ask for user confirmation unless specified
  82.     if not delete_files then
  83.       print("Press and hold Y to delete unused files. Press and hold any other key to exit")
  84.       while(true) do
  85.         local event, key, isHeld = os.pullEvent("key")
  86.         if isHeld then
  87.           if key == keys.y then
  88.             write("Deleting files.. ")
  89.             fs.delete("install.lua")
  90.             fs.delete("README.md")
  91.             fs.delete("CODE_OF_CONDUCT.md")
  92.             fs.delete(".gitignore")
  93.             fs.delete("Axiom/debug.lua")
  94.             sleep(.25)
  95.             print("OK")
  96.             break
  97.           else
  98.             break
  99.           end
  100.         end
  101.       end
  102.     else
  103.       write("Deleting files.. ")
  104.       fs.delete("install.lua")
  105.       fs.delete("README.md")
  106.       sleep(.25)
  107.       print("OK")
  108.     end
  109.   else
  110.     error("formatFS failed")
  111.   end
  112. end
  113. local function wget(url, file)
  114.   local data = http.get(url)
  115.   if data ~= nil then
  116.     data = data.readAll()
  117.     local file_handle = fs.open(file,"w")
  118.     file_handle.write(data)
  119.     file_handle.close()
  120.   else
  121.     error("Could not download "..file..", quitting..")
  122.   end
  123. end
  124. function selector(y,option)
  125.   term.setCursorPos(1,y)
  126.   for k,v in ipairs(branches) do
  127.     if k == option then
  128.       write(v.. " <-")
  129.       term.setCursorPos(1,y+k)
  130.     else
  131.       write(v.. "   ")
  132.       term.setCursorPos(1,y+k)
  133.     end
  134.   end
  135. end
  136. local version = os.version()
  137. if version == "CraftOS 1.5" then
  138.   error("Axiom is not compatible with "..version.."!")
  139. end
  140. print("AxiomUI Github Superfast(tm) Installer")
  141. if not skip_branch_select then
  142.   print("Select a branch:")
  143.  
  144.   local x,y = term.getCursorPos()
  145.   if y > 18 then
  146.     shell.run("clear")
  147.     print("Select a branch:")
  148.     x,y = term.getCursorPos()
  149.   end
  150.   selector(y,branch)
  151.   while(true) do
  152.     local e,k,h = os.pullEvent( "key" )
  153.     if k == keys.up then
  154.       if branch > 1 then
  155.         branch = branch - 1
  156.         selector(y,branch)
  157.       end
  158.     end
  159.     if k == keys.down then
  160.       if branch < #branches then
  161.         branch = branch + 1
  162.         selector(y,branch)
  163.       end
  164.     end
  165.     if k == keys.enter then
  166.       branch = branches[branch]
  167.       print("Branch selected: "..branch)
  168.       print("Starting installation")
  169.       break
  170.     end
  171.   end
  172. end
  173. wget("https://pastebin.com/raw/W5ZkVYSi",".gitget")
  174. shell.run(".gitget "..user.." axiom "..branch.." AxiomUI")
  175. formatFS()
  176. print("Installation completed.")
  177. if reboot then os.reboot() end
  178.  
Add Comment
Please, Sign In to add comment