Trystan_C_C

Shell Install Script

Nov 19th, 2012
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. local links = {
  2.       ["Main"] = {link = "EsDc0Kjt", path = "grimShellMain"},
  3.       ["Menu"] = {link = "tYhxmTBk", path = "GrimShell/menu"},
  4.       ["Screen"] = {link = "L9UqyZXB", path = "GrimShell/screen"},
  5.       ["Interface"] = {link = "rsNZVufk", path = "GrimShell/interface"},
  6.       ["Utilities"] = {link = "sCU7ZF3g", path = "GrimShell/utilities"},
  7.       ["Click"] = {link = "BW3MQECY", path = "GrimShell/click"},
  8.       ["Color"] = {link = "ynLqZDYq",path = "GrimShell/color"}
  9. }
  10.  
  11. -- Retrieves a file from pastebin using http.get, then
  12. -- saves it to the desired destination.
  13. function downloadFromPastebin(link, destination)
  14.       http.request("http://pastebin.com/raw.php?i=" .. textutils.urlEncode(link))
  15.      
  16.       while true do
  17.             local event, url, download = os.pullEvent()
  18.            
  19.             if event == "http_success" then
  20.                   if not fs.isDir("/GrimShell") then
  21.                         fs.makeDir("/GrimShell")
  22.                   end
  23.                  
  24.                   local file = fs.open(destination, 'w')
  25.                  
  26.                   local downloadContents = download.readAll()
  27.                   download.close()
  28.                   if file then
  29.                         file.write(downloadContents)
  30.                         file.close()
  31.                   else
  32.                         error(destination .. " already exists.")
  33.                   end
  34.                  
  35.                   return
  36.             elseif event == "http_failure" then
  37.                   error("Download from " .. lin .. " failed.")
  38.             end
  39.       end
  40. end
  41.  
  42. -- Downloads and installs all necessary APIs for the grim shell to
  43. -- run.
  44. function installShell()
  45.       for index, item in pairs(links) do
  46.             print("Installing " .. index .. " to " .. item.path)
  47.             downloadFromPastebin(item.link, item.path)
  48.       end
  49. end
  50.  
  51. installShell()
Advertisement
Add Comment
Please, Sign In to add comment