Advertisement
awsumben13

Phoenix Installer mk2

Sep 20th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. if not fs.isDir "Flare" then
  2.     shell.run "pastebin run SD25GhYf"
  3. end
  4.  
  5. local url = "https://raw.githubusercontent.com/Exerro/Phoenix/master/"
  6. local path = "Phoenix/"
  7. local files = {
  8.     "init.lua";
  9.     "apps/demo/config.lua";
  10.     "apps/demo/init.lua";
  11.     "apps/shell/config.lua";
  12.     "apps/shell/init.lua";
  13.     "bin/nethost.lua";
  14.     "bin/OS.lua";
  15.     "bin/rednethost.lua";
  16.     "bin/start.lua";
  17.     "lib/net/diffe-hellman.lua";
  18.     "lib/net/network.lua";
  19.     "lib/database.lua";
  20.     "lib/debug.lua";
  21.     "lib/encrypt.lua";
  22.     "lib/filesystem.lua";
  23.     "lib/process.lua";
  24.     "lib/sha256.lua";
  25.     "lib/user.lua";
  26. }
  27.  
  28. for i = 1, #files do
  29.     print( "Installing file " .. files[i] )
  30.     local h = http.get( url .. files[i] )
  31.     if h then
  32.         local content = h.readAll()
  33.         h.close()
  34.  
  35.         local h = fs.open( path .. files[i], "w" )
  36.         if h then
  37.             h.write( content )
  38.             h.close()
  39.         else
  40.             print "Failed to write file"
  41.             return
  42.         end
  43.     else
  44.         print "Failed to fetch file"
  45.         return
  46.     end
  47. end
  48.  
  49. local function movefile( file )
  50.     if fs.exists( "old" .. file ) then
  51.         movefile( "old" .. file )
  52.     end
  53.     fs.move( file, "old" .. file )
  54. end
  55.  
  56. if fs.exists "startup" then
  57.     movefile "startup"
  58. end
  59.  
  60. local h = fs.open( "startup", "w" )
  61. if h then
  62.     h.write [[shell.run "Phoenix/init.lua"]]
  63.     h.close()
  64. else
  65.     print "Failed to write startup"
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement