zahar0401

installer

Aug 7th, 2016
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 KB | None | 0 0
  1. local args = {...}
  2.  
  3. -- Help
  4. local function printUsage()
  5.     print([[
  6.     installer <mode>
  7.     Modes:
  8.     on-demand: only installs the On-Demand Scanner
  9.     rts: only installs the Real-Time Security Driver
  10.     suite: installs the entire suite
  11.     ]])
  12. end
  13.  
  14. -- The actual function replacing pastebin
  15. local function getData(code)
  16.     local file = http.get("http://pastebin.com/raw/"..code)
  17.     local contents = file.readAll()
  18.     file.close()
  19.     return contents
  20. end
  21.  
  22. -- A FS wrapper
  23. local function save(data, path)
  24.     if not fs.exists(path) then
  25.         local h = fs.open(path, "w")
  26.         h.write(data)
  27.         h.close()
  28.         return true
  29.     else
  30.         printError("FIle already exists!")
  31.         return false
  32.     end
  33. end
  34.  
  35. -- GUI (kind of)
  36. local function clear()
  37.     term.clear()
  38.     term.setCursorPos(1,1)
  39. end
  40.  
  41. local function drawProgress(txt, y)
  42.     term.setCursorPos(4, 4)
  43.     print(txt)
  44.     term.setCursorPos(1, y)
  45.     print("[                             ]")
  46.     term.setCursorPos(2, y)
  47.     textutils.slowPrint("==============================]", 10)
  48.     print("Done!")
  49. end
  50.  
  51. local function draw()
  52.     print("ReactOS AntiMalware Suite              | Installer ")
  53.     print("___________________________________________________")
  54. end
  55.  
  56. -- Main code
  57. clear()
  58. draw()
  59. if #args < 1 then
  60.     printUsage()
  61. else
  62.     if args[1] == "on-demand" then
  63.         drawProgress("Downloading BLAST On-Demand Scanner.", 6)
  64.         save(getData("pUG2n5Hb"), "scan")
  65.     elseif args[1] == "rts" then
  66.         drawProgress("Downloading BLAST Real-Time Security Driver.", 6)
  67.         save(getData("gZvWiXJ7"), "rts")
  68.     elseif args[1] == "suite" then
  69.         drawProgress("Downloading BLAST AntiMalware Suite.", 6)
  70.         save(getData("pUG2n5Hb"), "scan")
  71.         save(getData("gZvWiXJ7"), "rts")
  72.     else
  73.         printUsage()
  74.     end
  75. end
Advertisement
Add Comment
Please, Sign In to add comment