pepeknamornik

P7 INSTALLER Computercraft

Oct 18th, 2021
691
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local w, h = term.getSize()
  2. local krok = "edition"
  3. local evybrat = ""
  4. local tArgs = { ... }
  5. local modem = ""
  6. local adID = nil
  7. local adUser = ""
  8. local adPass = ""
  9. local rfreq = 0
  10. local i = 0
  11. local idPC = os.getComputerID()
  12. local modemC = ""
  13. local nUser = "Administrator"
  14. local nPass = ""
  15. local cPass = ""
  16. local barvy = {"2048", "2048","16384", "8192"}
  17. local BarvaI = tonumber(barvy[math.random(1, 4)])
  18.  
  19.  
  20. local function prc(text, y)
  21.   local w = term.getSize()
  22.   local _, cy = term.getCursorPos()
  23.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  24.   write(text)
  25. end
  26.  
  27. function restarting ()
  28.     term.setBackgroundColor(colors.lightGray)
  29.     term.clear()
  30.     sleep (0.1)
  31.     term.setBackgroundColor(colors.gray)
  32.     term.clear()
  33.     sleep (0.1)
  34.     term.setBackgroundColor(colors.black)
  35.     term.setTextColor(colors.black)
  36.     term.clear()
  37.     term.setBackgroundColor(colors.white)
  38.     term.setTextColor(colors.black)
  39.     term.clear()
  40.     term.setCursorPos(w/2-6, h/2)
  41.     write "Restarting..."
  42.     term.setBackgroundColor(colors.white)
  43.     term.setTextColor(colors.blue)
  44.     term.setCursorPos(w/2-5,h-1)
  45.     write "  Pepek"
  46.     term.setCursorPos(w/2+3,h-1)
  47.     write "Soft  "
  48.     term.setCursorPos(w/2+2,h-1)
  49.     term.setTextColor(colors.lime)
  50.     write "@"
  51.     sleep(1)
  52.     os.reboot ()
  53. end
  54.  
  55. local function downloading(kod, cestaP)
  56.     local WinDown = window.create(term.current(),15,8,w-15,5)
  57.     WinDown.setBackgroundColor(colors.lightGray)
  58.     WinDown.clear()
  59.     WinDown.setTextColor(colors.black)
  60.     WinDown.setCursorPos(2,1)
  61.     WinDown.write "Downloading files..."
  62.     term.setCursorPos(1,-5)
  63.     term.setBackgroundColor(colors.lightGray)
  64.     shell.run("pastebin get "..kod.." "..cestaP)
  65.    
  66. end
  67.  
  68. function start()
  69. shell.run("pastebin get GssKCexp /stahni.lua")
  70.     if (krok == "edition") then
  71.         edice()
  72.     elseif (krok == "install") then
  73.         instalace()
  74.     elseif (krok == "network") then
  75.         network()
  76.     elseif (krok == "account") then
  77.         account()
  78.     elseif (krok == "end") then
  79.         fs.delete("/stahni.lua")
  80.         restarting()
  81.     end
  82. term.setCursorPos(1,1)
  83. end
  84.  
  85. function pozadi()
  86.  
  87. local myWindow = window.create(term.current(),1,1,12,h)
  88. myWindow.setBackgroundColor(BarvaI)
  89. myWindow.clear()
  90.  
  91. myWindow.setCursorPos(2,5)
  92. if (krok == "edition") then myWindow.setTextColor(colors.lightGray) else myWindow.setTextColor(colors.white) end
  93. myWindow.write("- Edition")
  94. myWindow.setCursorPos(2,7)
  95. if (krok == "install") then myWindow.setTextColor(colors.lightGray) else myWindow.setTextColor(colors.white) end
  96. myWindow.write("- Install")
  97. myWindow.setCursorPos(2,9)
  98. if (krok == "network") then myWindow.setTextColor(colors.lightGray) else myWindow.setTextColor(colors.white) end
  99. myWindow.write("- Network")
  100. myWindow.setCursorPos(2,11)
  101. if (krok == "account") then myWindow.setTextColor(colors.lightGray) else myWindow.setTextColor(colors.white) end
  102. myWindow.write("- Account")
  103. myWindow.setCursorPos(2,h)
  104. myWindow.setTextColor(colors.white)
  105. myWindow.write("Pepek@Soft")
  106.  
  107. plocha = window.create(term.current(),13,1,w-12,h)
  108. ww = w-12
  109. plocha.setBackgroundColor(colors.white)
  110. plocha.clear()
  111. plocha.setTextColor(colors.black)
  112. plocha.setCursorPos(ww/2-12,1) 
  113. plocha.write("Pepdroll Seven Installer")
  114.  
  115. plocha.setBackgroundColor(colors.lightGray)
  116. plocha.setCursorPos(ww/2-4,h-1)
  117. plocha.write" Next "
  118. plocha.setBackgroundColor(colors.white)
  119. plocha.setTextColor(colors.black)
  120. end
  121.  
  122. function edice()
  123.     pozadi()
  124.     plocha.setBackgroundColor(colors.lightGray)
  125.     plocha.setCursorPos(ww/2-5,h-1)
  126.     plocha.write" Install "
  127.     plocha.setBackgroundColor(colors.white)
  128.     local eClient = window.create(term.current(),15,5,w-15,5)
  129.     if (evybrat == "client") then
  130.     eClient.setBackgroundColor(colors.lightBlue)
  131.     else
  132.     eClient.setBackgroundColor(colors.lightGray)
  133.     end
  134.     eClient.clear()
  135.     eClient.setTextColor(colors.black)
  136.     eClient.setCursorPos(2,1)
  137.     eClient.write "Standard"
  138.     eClient.setTextColor(colors.white)
  139.     eClient.setCursorPos(2,3)
  140.     eClient.write "Client with basic functions and"
  141.     eClient.setCursorPos(2,4)
  142.     eClient.write "connectivity to the corporate net"
  143.  
  144.  
  145.     local eServer = window.create(term.current(),15,12,w-15,5)
  146.     if (evybrat == "server") then
  147.     eServer.setBackgroundColor(colors.lightBlue)
  148.     else
  149.     eServer.setBackgroundColor(colors.lightGray)
  150.     end
  151.     eServer.clear()
  152.     eServer.setTextColor(colors.black)
  153.     eServer.setCursorPos(2,1)
  154.     eServer.write "Server"
  155.     eServer.setTextColor(colors.white)
  156.     eServer.setCursorPos(2,3)
  157.     eServer.write "Server with many features to setup"
  158.     eServer.setCursorPos(2,4)
  159.     eServer.write "Designed for clients with Pepdroll"
  160.     eServer.setCursorPos(2,5)
  161.     eServer.write "Standard Edition."
  162.  
  163.    
  164.     while true do
  165.     event, button, x,y = os.pullEvent()
  166.                        
  167.         if event == "mouse_click" and x >= 15 and x<= w-1 and y >= 5 and y <= 10 and button == 1 then
  168.         evybrat = "client"
  169.         edice()
  170.         elseif event == "mouse_click" and x >= 15 and x<= w-1 and y >= 12 and y <= 17 and button == 1 then
  171.         evybrat = "server"
  172.         edice()
  173.         elseif event == "mouse_click" and x >= 25 and x<= 34 and y == h-1 and button == 1 then
  174.         plocha.setBackgroundColor(colors.gray)
  175.         plocha.setCursorPos(ww/2-5,h-1)
  176.         plocha.write" Install "
  177.         sleep(0.1)
  178.  
  179.         if (evybrat == "") then
  180.             edice()
  181.         else
  182.             krok = "install"
  183.             start()
  184.         end
  185.        
  186.         end
  187.     end
  188. end
  189.  
  190. function instalace()
  191. pozadi()
  192. plocha.setCursorPos(ww/2-16,5) 
  193. plocha.write("Install is in progress, please wait")
  194. downloading("0xh6jEx1", "/startup.lua") -- startup
  195. downloading("HyhMtGvd", "/C/system/.core/desktop.lua") -- desktop
  196. downloading("EEVJPR7F", "/C/system/api/closeAPP")
  197. downloading("DSNcZuMZ", "/C/system/api/bluescreen.lua")
  198. downloading("vxJjQzem", "/C/setting.lua")
  199. downloading("XBXHNqS1", "/LICENSE.txt")
  200. if (evybrat == "server") then
  201. downloading("z02yAN3M", "/C/Programs/PepekSoft/smanager.lua")
  202. fs.makeDir("/server")
  203. end
  204.  
  205. local sf = fs.open("/startup", "w")
  206. sf.writeLine("shell.run(\"/startup.lua\")")
  207. sf.close()
  208.  
  209. krok = "network"
  210. start()
  211.     while true do
  212.     event, button, x,y = os.pullEvent()
  213.     end
  214. end
  215.  
  216. function defmodem(size)
  217. local dm = fs.open("/C/system/.core/defmodem","w")
  218. dm.writeLine(size)
  219. dm.close()
  220. end
  221.  
  222. function prijmout()
  223. local odpoved = false
  224. timerRX = os.startTimer(2)
  225.     while true do
  226.     local event,p1,p2,p3,p4 = os.pullEvent()
  227.       if event == ("modem_message") then
  228.           if (p3 == 552) then
  229.             odpoved = true
  230.                 if (p4 == "true") then
  231.                 local c = fs.open ("/C/system/.core/AD", "w")
  232.                 c.writeLine(tostring(adID))
  233.                 c.close()
  234.                 plocha.setCursorPos(2,17)
  235.                 plocha.setTextColor(colors.green)
  236.                 plocha.write"Successfully connected to the server."
  237.                 sleep(0.5)
  238.                 local ucet = fs.open("/C/system/.core/ucet","w")
  239.                 ucet.close()
  240.                 o=fs.open ("/C/system/.core/defuser", "w")
  241.                 o.writeLine(adUser)
  242.                 o.close()
  243.                 restarting ()
  244.                 else
  245.                 plocha.setCursorPos(2,17)
  246.                 plocha.setTextColor(colors.red)
  247.                 plocha.write"Error, invalid login!"
  248.                 sleep(0.5)
  249.                 end
  250.             end
  251.       elseif event == "timer" then
  252.         if p1 >= timerRX then
  253.         plocha.setCursorPos(2,17)
  254.         plocha.setTextColor(colors.red)
  255.         if not odpoved then plocha.write"Error, server not found!" sleep(1) end
  256.         network()
  257.         end
  258.       end
  259.     end
  260. end
  261.  
  262. function dotaz()
  263.     if adUser ~= "" and adID ~= nil then
  264.         modemC.open(idPC)
  265.         modemC.transmit(tonumber(adID),550,idPC)
  266.         modemC.transmit(tonumber(adID),551,adUser)
  267.         modemC.transmit(tonumber(adID),552,adPass)
  268.         prijmout()
  269.     end
  270. end
  271.  
  272. function ServerManager()
  273. local sf = fs.open("/C/system/Users/"..nUser.."/Desktop/SrvMan.src", "w")
  274. sf.writeLine("shell.run(\"/C/Programs/PepekSoft/smanager.lua\")")
  275. sf.close()
  276. end
  277.  
  278. function network()
  279. pozadi()
  280. if fs.exists("/C/system/.core/defmodem") then
  281.     s = fs.open("/C/system/.core/defmodem","r")
  282.     modem = s.readLine()
  283.     s.close()
  284.     AD = true
  285.     modemE = peripheral.wrap(modem)
  286.     if not modemE then
  287.     fs.delete("/C/system/.core/defmodem")
  288.     network()
  289.     end
  290.  
  291. else
  292.     modem = "offline"
  293.     AD = false
  294. end
  295.  
  296. plocha.setCursorPos(2,3)
  297. plocha.write"Choose your primary modem."
  298. if not (modem == "offline") then
  299. plocha.setCursorPos(2,11)
  300. plocha.write"If you already have an AD server,"
  301. plocha.setCursorPos(2,12)
  302. plocha.write" you can connect here."
  303. plocha.setCursorPos(2,14)
  304. plocha.write"Server  ID:"
  305. plocha.setCursorPos(2,15)
  306. plocha.write"Admin user:"
  307. plocha.setCursorPos(2,16)
  308. plocha.write"Admin pass:"
  309. plocha.setBackgroundColor(colors.lightGray)
  310. plocha.setCursorPos(14,14)
  311. plocha.write"               "
  312. if not (adID == nil) then plocha.setCursorPos(15,14) plocha.write(tostring(adID)) end
  313. plocha.setCursorPos(14,15)
  314. plocha.write"               "
  315. if not (adUser == "") then plocha.setCursorPos(15,15) plocha.write(adUser) end
  316. plocha.setCursorPos(14,16)
  317. plocha.write"               "
  318. if not (adPass == "") then plocha.setCursorPos(15,16) plocha.write("Password") end
  319. end
  320. plocha.setBackgroundColor(colors.white)
  321. plocha.setTextColor(colors.lightGray)
  322. plocha.setCursorPos(1,4)
  323. plocha.write"The settings can be changed at any time!"
  324. plocha.setTextColor(colors.black)
  325. plocha.setBackgroundColor(colors.lightGray)
  326. plocha.setCursorPos(8,5)
  327. if (modem == "top") then plocha.setBackgroundColor(colors.gray) else plocha.setBackgroundColor(colors.lightGray) end
  328. plocha.write" TOP     "
  329. plocha.setCursorPos(8,7)
  330. if (modem == "left") then plocha.setBackgroundColor(colors.gray) else plocha.setBackgroundColor(colors.lightGray) end
  331. plocha.write" LEFT    "
  332. plocha.setCursorPos(8,9)
  333. if (modem == "right") then plocha.setBackgroundColor(colors.gray) else plocha.setBackgroundColor(colors.lightGray) end
  334. plocha.write" RIGHT   "
  335. plocha.setCursorPos(20,5)
  336. if (modem == "back") then plocha.setBackgroundColor(colors.gray) else plocha.setBackgroundColor(colors.lightGray) end
  337. plocha.write" BACK    "
  338. plocha.setCursorPos(20,7)
  339. if (modem == "bottom") then plocha.setBackgroundColor(colors.gray) else plocha.setBackgroundColor(colors.lightGray) end
  340. plocha.write" BOTTOM  "
  341. plocha.setCursorPos(20,9)
  342. if (modem == "offline") then plocha.setBackgroundColor(colors.gray) else plocha.setBackgroundColor(colors.lightGray) end
  343. plocha.write" OFFLINE "
  344.  
  345.     while true do
  346.     event, button, x,y = os.pullEvent()
  347.    
  348.     if event == "mouse_click" and x >= 20 and x<= 28 and y == 5 and button == 1 then
  349.     defmodem("top")
  350.     network()
  351.     elseif event == "mouse_click" and x >= 32 and x<= 40 and y == 5 and button == 1 then
  352.     defmodem("back")
  353.     network()
  354.     elseif event == "mouse_click" and x >= 20 and x<= 28 and y == 7 and button == 1 then
  355.     defmodem("left")
  356.     network()
  357.     elseif event == "mouse_click" and x >= 32 and x<= 40 and y == 7 and button == 1 then
  358.     defmodem("bottom")
  359.     network()
  360.     elseif event == "mouse_click" and x >= 20 and x<= 28 and y == 9 and button == 1 then
  361.     defmodem("right")
  362.     network()
  363.     elseif event == "mouse_click" and x >= 32 and x<= 40 and y == 9 and button == 1 then
  364.         if fs.exists("/C/system/.core/defmodem") then
  365.             fs.delete("/C/system/.core/defmodem")
  366.         end
  367.     network()
  368.     elseif event == "mouse_click" and x >= 26 and x<= 40 and y == 14 and AD and button == 1 then
  369.     term.setBackgroundColor(colors.lightBlue)
  370.     plocha.setBackgroundColor(colors.lightBlue)
  371.     plocha.setCursorPos(14,14)
  372.     plocha.write"               "
  373.     plocha.setCursorPos(15,14)
  374.     adID = read()
  375.     network()
  376.     elseif event == "mouse_click" and x >= 26 and x<= 40 and y == 15 and AD and button == 1 then
  377.     term.setBackgroundColor(colors.lightBlue)
  378.     plocha.setBackgroundColor(colors.lightBlue)
  379.     plocha.setCursorPos(14,15)
  380.     plocha.write"               "
  381.     plocha.setCursorPos(15,15)
  382.     adUser = read()
  383.     network()
  384.     elseif event == "mouse_click" and x >= 26 and x<= 40 and y == 16 and AD and button == 1 then
  385.     term.setBackgroundColor(colors.lightBlue)
  386.     plocha.setBackgroundColor(colors.lightBlue)
  387.     plocha.setCursorPos(14,16)
  388.     plocha.write"               "
  389.     plocha.setCursorPos(15,16)
  390.     adPass = read("x")
  391.     network()
  392.     elseif event == "mouse_click" and x >= 27 and x<= 32 and y == h-1 and button == 1 then
  393.         plocha.setBackgroundColor(colors.gray)
  394.         plocha.setCursorPos(ww/2-4,h-1)
  395.         plocha.write" Next "
  396.         sleep(0.1)
  397.         plocha.setBackgroundColor(colors.white)
  398.         if AD then
  399.         modemC = peripheral.wrap(modem)
  400.         dotaz()
  401.         end
  402.         krok = "end"
  403.         start()
  404.     end
  405.    
  406.     end
  407. end
  408.  
  409. start()
RAW Paste Data