Advertisement
DOGGYWOOF

Network Lock

Feb 29th, 2024 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. -- Initialize monitors
  2. local leftMonitor = peripheral.wrap("left")
  3. local rightMonitor = peripheral.wrap("right")
  4.  
  5. -- Function to display messages on the left monitor
  6. local function displayLeftMonitorMessage(message)
  7. leftMonitor.clear()
  8. leftMonitor.setCursorPos(1, 1)
  9. leftMonitor.write(message)
  10. end
  11.  
  12. -- Function to display messages on the right monitor
  13. local function displayRightMonitorMessage(message)
  14. rightMonitor.clear()
  15. rightMonitor.setCursorPos(1, 1)
  16. rightMonitor.write(message)
  17. end
  18.  
  19. -- Function to ask for user input (yes or no)
  20. local function askForUserInput(prompt)
  21. term.clear()
  22. term.setCursorPos(1, 1)
  23. print(prompt)
  24. return read()
  25. end
  26.  
  27. -- Function to block the device
  28. local function blockDevice()
  29. displayLeftMonitorMessage("Enterprise admin blocked this device")
  30. displayRightMonitorMessage("Device Blocked by Network Administrator")
  31. sleep(2)
  32. local userInput = askForUserInput("Press Enter to reboot the device...")
  33. if userInput == "" then
  34. os.reboot()
  35. end
  36. end
  37.  
  38. -- Function to unblock the device
  39. local function unblockDevice()
  40. displayLeftMonitorMessage("Device Has been Unblocked by an administrator")
  41. displayRightMonitorMessage("Device Unlocked, Reboot to Network Lock")
  42. sleep(2)
  43. local userInput = askForUserInput("Press Enter to reboot the device...")
  44. if userInput == "" then
  45. os.reboot()
  46. end
  47. end
  48.  
  49. -- Main function
  50. local function main()
  51. local passwordFile = "/Network/password.txt"
  52.  
  53. if fs.exists(passwordFile) then
  54. blockDevice()
  55. else
  56. local userInput = askForUserInput("Access device installed OS and storage using Network Administrator Password? (yes/no)")
  57. if userInput:lower() == "yes" then
  58. unblockDevice()
  59. else
  60. os.reboot()
  61. end
  62. end
  63. end
  64.  
  65. -- Run the program
  66. main()
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement