Advertisement
Guest User

startup

a guest
Mar 12th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.78 KB | None | 0 0
  1. ver = '1.0.1'
  2. shell.run("rm check")
  3. --Prepare the computer
  4. check = "ver = '1.0.1'"
  5. rednet.open("back")
  6. shell.run("clear")
  7. --Clear function
  8. function user()
  9.     write("Enter username: ")
  10.     u = string.lower(read())
  11.     write("Enter password: ")
  12.     p = read("*")
  13.     if u == "supercoolguy855" and p == "Ilovechariskship" then
  14.         admin = 1
  15.         login = 1
  16.     elseif u == "guest" and p == "1234" then
  17.         admin = 0
  18.         login = 1
  19.     else
  20.         admin = 0
  21.         login = 0
  22.     end
  23. end
  24. function clear()
  25.     shell.run("clear")
  26.     term.setTextColor(colors.red)
  27.     write("Central ")
  28.     term.setTextColor(colors.orange)
  29.     write("Control ")
  30.     term.setTextColor(colors.yellow)
  31.     write("Command ")
  32.     term.setTextColor(colors.lime)
  33.     print("v" ..  ver)
  34.     term.setTextColor(colors.green)
  35.     print("Enter command:")
  36. end
  37. --News function
  38. function new()
  39.     print("Version", ver, "added:")
  40. end
  41. --Function admin
  42. function notadmin()
  43.     print("Please run this command under administrator permission")
  44.     sleep(1)
  45.     os.reboot()
  46. end
  47. --Program function
  48. function program()
  49.     e1 = string.lower(read())
  50.     if e1 == "backup" then
  51.         if admin == 1 then
  52.             shell.run("rm startup")
  53.             shell.run("cp backup startup")
  54.             os.reboot()
  55.         else
  56.             notadmin()
  57.         end
  58.     end
  59.     if e1 == "clear" then
  60.         clear()
  61.         e1 = string.lower(read())
  62.     end
  63.     if e1 == "shutdown" then
  64.         os.shutdown()
  65.     end
  66.     if e1 == "check" then
  67.         if admin == 1 then
  68.             shell.run("pastebin get WWcEkWD5 check")
  69.             h = fs.open("check","r")
  70.             c = h.readLine()
  71.             if c ~= check then
  72.                 print("There is a newer version")
  73.                 write("Do you want to update this (Y/N):")
  74.                 yesorno = string.lower(read())
  75.                 if yesorno == "y" then
  76.                     shell.run("rm backup")
  77.                     shell.run("mv startup backup")
  78.                     shell.run("mv check startup")
  79.                     os.reboot()
  80.                 else
  81.                     os.reboot()
  82.                 end
  83.             else
  84.                 print("This is the latest version")
  85.                 sleep(2)
  86.                 os.reboot()
  87.             end
  88.         else
  89.             notadmin()
  90.         end
  91.     end
  92.     if e1 == "update" then
  93.         if admin == 1 then
  94.             shell.run("rm backup")
  95.             shell.run("cp startup backup")
  96.             shell.run("pastebin get WWcEkWD5 startup")
  97.         else
  98.             notadmin()
  99.         end
  100.     end
  101.     if e1 == "new" then
  102.         print("Version", ver, "has:")
  103.         read()
  104.         os.reboot()
  105.     end
  106.     if e1 == "help" then
  107.         print("Enter a command here")
  108.         write("Here is a list of command: ")
  109.         print("light, door")
  110.         e1 = read()
  111.     end
  112.     if e1 == "hack" then
  113.         if admin == 1 then
  114.             shell.run("clear")
  115.             print("Hacking protocol for Minh's devices")
  116.             write("One or All: ")
  117.             t = string.lower(read())
  118.             if t == "one" then
  119.                 write("Enter the protocol: ")
  120.                 pro = string.lower(read())
  121.                 write("Enter the ID of the computer: ")
  122.                 x = tonumber(read())
  123.                 write("True of false: ")
  124.                 w = string.lower(read())
  125.                 rednet.send(x,w,pro)
  126.             end
  127.             if t == "all" then
  128.                 write("Enter a protocol: ")
  129.                 pro = string.lower(read())
  130.                 write("True or False: ")
  131.                 w = string.lower(read())
  132.                 rednet.broadcast(w,pro)
  133.             end
  134.             os.reboot()
  135.         else
  136.             notadmin()
  137.         end
  138.     end
  139.     e2 = string.lower(read())
  140.     if e2 == "help" then
  141.         print("Enter a room")
  142.         write("Here is a list: ")
  143.         print("bathroom, bedroom, living room, kitchen, basement,level2")
  144.         print(e1)
  145.         e2 = string.lower(read())
  146.     end
  147.     if e1 == "rollback" then
  148.         if admin == 1 then
  149.             if e2 == "create" then
  150.                 shell.run("rm rollback")
  151.                 shell.run("cp startup rollback")
  152.             end
  153.             if e2 == "restore" then
  154.                 shell.run("rm startup")
  155.                 shell.run("cp rollback startup")
  156.             end
  157.             os.reboot()
  158.         else
  159.             notadmin()
  160.         end
  161.     end
  162.     e3 = string.lower(read())
  163.     if e3 == "help" then
  164.         print("Enter true or false")
  165.         print(e1)
  166.         print(e2)
  167.     end
  168.     print("-------------")
  169.     --Actual program
  170.     if e1 == "light" then
  171.         if e2 == "bathroom" then
  172.             x = 45
  173.         elseif e2 == "bedroom" then
  174.             x = 44
  175.         elseif e2 == "kitchen" then
  176.             x = 43
  177.         elseif e2 == "living room" then
  178.             x = 48
  179.         elseif e2 == "all" then
  180.             x = 180503
  181.         elseif e2 == "basement" then
  182.             x = 65
  183.         elseif e2 == "level2" then
  184.             x = 77
  185.         end
  186.         if e3 == "on" then
  187.             y = "true"
  188.         elseif e3 == "off" then
  189.             y = "false"
  190.         end
  191.         if x == 180503 then
  192.             rednet.broadcast(y,"home")
  193.         else
  194.             rednet.send(x,y,"home")
  195.         end
  196.     end
  197.     if e1 == "door" then
  198.         if e2 == "basement" then
  199.             x = 56
  200.         elseif e2 == "exit" then
  201.             x = 64
  202.         elseif e2 == "level2" then
  203.             x = 78
  204.         end
  205.         if e3 == "open" then
  206.             y = "true"
  207.         elseif e3 == "close" then
  208.             y = "false"
  209.         end
  210.         rednet.send(x,y,"door")
  211.     end
  212. end
  213. function loopro()
  214.     clear()
  215.     while true do
  216.         program()
  217.     end
  218. end
  219. --Booting up sequence
  220. function booting()
  221.     term.setTextColor(colors.red)
  222.     print("[Booting Sequence Initiated]")
  223.     sleep(0.1)
  224.     print("[Operating System Initiating]")
  225.     sleep(0.1)
  226.     print("[Operating System Initiated]")
  227.     sleep(0.1)
  228.     print("[Hacking Protocol Activating]")
  229.     sleep(0.1)
  230.     print("[Hacking Protocol Activated]")
  231.     sleep(0.1)
  232.     print("[Wireless Modem Initiating]")
  233.     sleep(0.1)
  234.     print("[Wireless Modem Initiated]")
  235.     sleep(0.1)
  236.     print("[Extending RAM]")
  237.     sleep(1)
  238.     print("[RAM Extended]")
  239.     sleep(0.1)
  240.     print("[CPU Initiating]")
  241.     sleep(1)
  242.     print("[CPU Initiated]")
  243.     print("[Booting Sequence Completed]")
  244.     sleep(1)
  245.     term.setTextColor(colors.white)
  246.     shell.run("clear")
  247. end
  248. --Looping program
  249. function loop()
  250.     while true do
  251.         program()
  252.     end
  253. end
  254. --User information
  255. booting()
  256. user()
  257. if login == 1 then
  258.     clear()
  259.     loop()
  260. else
  261.     print("Wrong username or/and password")
  262.     sleep(2)
  263.     os.shutdown()
  264. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement