Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Initialize monitors
- local leftMonitor = peripheral.wrap("left")
- local rightMonitor = peripheral.wrap("right")
- -- Function to display messages on the left monitor
- local function displayLeftMonitorMessage(message)
- leftMonitor.clear()
- leftMonitor.setCursorPos(1, 1)
- leftMonitor.write(message)
- end
- -- Function to display messages on the right monitor
- local function displayRightMonitorMessage(message)
- rightMonitor.clear()
- rightMonitor.setCursorPos(1, 1)
- rightMonitor.write(message)
- end
- -- Function to ask for user input (yes or no)
- local function askForUserInput(prompt)
- term.clear()
- term.setCursorPos(1, 1)
- print(prompt)
- return read()
- end
- -- Function to block the device
- local function blockDevice()
- displayLeftMonitorMessage("Enterprise admin blocked this device")
- displayRightMonitorMessage("Device Blocked by Network Administrator")
- sleep(2)
- local userInput = askForUserInput("Press Enter to reboot the device...")
- if userInput == "" then
- os.reboot()
- end
- end
- -- Function to unblock the device
- local function unblockDevice()
- displayLeftMonitorMessage("Device Has been Unblocked by an administrator")
- displayRightMonitorMessage("Device Unlocked, Reboot to Network Lock")
- sleep(2)
- local userInput = askForUserInput("Press Enter to reboot the device...")
- if userInput == "" then
- os.reboot()
- end
- end
- -- Main function
- local function main()
- local passwordFile = "/Network/password.txt"
- if fs.exists(passwordFile) then
- blockDevice()
- else
- local userInput = askForUserInput("Access device installed OS and storage using Network Administrator Password? (yes/no)")
- if userInput:lower() == "yes" then
- unblockDevice()
- else
- os.reboot()
- end
- end
- end
- -- Run the program
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement