Advertisement
jesusthekiller

Installer_WCON

Mar 29th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.72 KB | None | 0 0
  1.     local function clear()
  2.             term.clear()
  3.             term.setCursorPos(1,1)
  4.     end
  5.      
  6.     if not http then
  7.             print( "WCON requires http API" )
  8.             print( "Set enableAPI_http to 1 in mod_ComputerCraft.cfg" )
  9.             return
  10.     end
  11.      
  12.     print("Welcome to WCON installer.")
  13.     print("Do you have an WCON account for this compuer? (Y/N)")
  14.     while ((e1 ~= "y" and e1 ~= "Y") and (e1 ~= "n" and e1 ~= "N")) do
  15.             e1 = read()
  16.     end
  17.      
  18.     if(e1 == "y" or e1 == "Y") then
  19.             clear()
  20.             print("Your ID:")
  21.             id = read()
  22.             print("Your password:")
  23.             pass = read()
  24.     elseif(e1 == "n" or e1 == "N") then
  25.             print("\nOK! Input your password: ")
  26.             local p = read()
  27.            
  28.             clear()
  29.            
  30.             print("Connecting to WCON server...")
  31.             local resp = http.get("http://mindblow.no-ip.org/wcon/api/mkAccount.php?pass="..p)
  32.            
  33.             if(resp == nil) then
  34.                     print("Oops, communicatio fail! Please visit mindblow.no-ip.org/wcon and register computer manually")
  35.                     return
  36.             end
  37.            
  38.             id = resp.readLine()
  39.             pass = resp.readLine()
  40.            
  41.             print("Done! Your ID is: "..tostring(id).." and password is: "..tostring(pass))
  42.             print("Write it down, it's impossible to get it back!")
  43.     end
  44.    
  45.     sleep(3)
  46.    
  47.     print("Installing...")
  48.      
  49.     print("Making wcon_stuff dir...")
  50.      
  51.     fs.makeDir("wcon_stuff")
  52.      
  53.     print("Downloading WCON API...")
  54.      
  55.     wcon = fs.open("wcon", "w")
  56.     wcon.write("local id = "..id.."\n")
  57.     wcon.write("local password=\""..pass.."\"\n")
  58.      
  59.     hver = http.get("http://mindblow.no-ip.org/wcon/api/version")
  60.     ver = hver.readLine()
  61.     hver.close()
  62.      
  63.     wcon.write("local ver = "..ver.."\n")
  64.      
  65.     file = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode("RKbavkNe"))
  66.      
  67.     if file == nil then print("Error!") return end
  68.      
  69.     wcon.write(file.readAll())
  70.      
  71.     file.close()
  72.     wcon.close()
  73.      
  74.     print("Downloading update...")
  75.      
  76.     update = fs.open("wcon_stuff/update", "w")
  77.      
  78.     file = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode("ry12vuie"))
  79.      
  80.     if file == nil then print("Error!") return end
  81.      
  82.     update.write(file.readAll())
  83.      
  84.     file.close()
  85.     update.close()
  86.      
  87.     print("Downloading launch...")
  88.      
  89.     launch = fs.open("launch", "w")
  90.      
  91.     file = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode("7EaDxV1e"))
  92.      
  93.     launch.write(file.readAll())
  94.      
  95.     file.close()
  96.     launch.close()
  97.      
  98.     print("Downloading update_check...")
  99.      
  100.     u_check = fs.open("wcon_stuff/update_check", "w")
  101.      
  102.     file = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode("D1e06P2r"))
  103.      
  104.     u_check.write(file.readAll())
  105.      
  106.     file.close()
  107.     u_check.close()
  108.      
  109.     print("Done!")
  110.      
  111.     print("\nDo you want to append update check the end of the startup file? (Y/N)")
  112.    
  113.     e1 = nil
  114.    
  115.     while (e1 ~= "y" and e1 ~= "Y" and e1 ~= "n" and e1 ~= "N") do
  116.             e1 = read()
  117.     end
  118.      
  119.     if(e1 == "y" or e1 == "Y") then
  120.             startup = fs.open("startup", "a")
  121.             startup.write("shell.run(\"wcon_stuff/update_check\")")
  122.             startup.close()
  123.             print("Done! You can always update manually by running \'wcon_stuff/update_check\'")
  124.     elseif(e1 == "n" or e1 == "N") then
  125.             print("OK :(. You can always update by running \'wcon_stuff/update_check\'")
  126.     end
  127.      
  128.     print("Installation complete!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement