Advertisement
Tatantyler

RPC-Based SSH Installer

Oct 29th, 2012
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. local clientID = "7aEnmrvX"
  2. local serverID = "WL0P040B"
  3. local rpcID = "AJEnqBtA"
  4.  
  5. local startup = [[
  6. for i,v in ipairs(rs.getSides()) do
  7.     if peripheral.getType(v) == "modem" then
  8.         rednet.open(v)
  9.     end
  10. end
  11. os.loadAPI("rpc")
  12. term.clear()
  13. term.setCursorPos(1,1)
  14. if fs.exists("startup2") then
  15.     parallel.waitForAll(function() shell.run("startup2") end, rpc.run)
  16. else
  17.     parallel.waitForAll(function() shell.run("shell") end, rpc.run)
  18. end
  19. ]]
  20.  
  21. if not fs.exists("rpc") then
  22.     local webHandle = http.get("http://pastebin.com/raw.php?i="..rpcID)
  23.     local data = webHandle.readAll()
  24.     webHandle.close()
  25.     local fileHandle = fs.open("rpc", "w")
  26.     fileHandle.write(data)
  27.     fileHandle.close()
  28. end
  29.  
  30. local selection = 0
  31.  
  32. while true do
  33.     term.clear()
  34.     term.setCursorPos(1,1)
  35.     print("RPC - Based SSH Installer")
  36.     print("Please make a selection:")
  37.     print("1 - Client")
  38.     print("2 - Server")
  39.     write("> ")
  40.     selection = tonumber(read())
  41.     if selection then
  42.         if selection == 1 or selection == 2 then
  43.             break
  44.         end
  45.     end
  46. end
  47.  
  48. if selection == 1 then
  49.     local webHandle = http.get("http://pastebin.com/raw.php?i="..clientID)
  50.     local data = webHandle.readAll()
  51.     webHandle.close()
  52.     local fileHandle = fs.open("client", "w")
  53.     fileHandle.write(data)
  54.     fileHandle.close()
  55. elseif selection == 2 then
  56.     local webHandle = http.get("http://pastebin.com/raw.php?i="..serverID)
  57.     local data = webHandle.readAll()
  58.     webHandle.close()
  59.     local fileHandle = fs.open("server", "w")
  60.     fileHandle.write(data)
  61.     fileHandle.close()
  62.     if fs.exists("startup") then
  63.         fs.copy("startup", "startup2")
  64.     end
  65.     local fileHandle = fs.open("startup", "w")
  66.     fileHandle.write(startup)
  67.     fileHandle.close()
  68. end
  69.  
  70. print("Finished.")
  71. os.sleep(2)
  72. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement