Advertisement
DOGGYWOOF

wire check status beta

Mar 1st, 2024
3
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. -- Function to check if a peripheral is a modem
  2. local function isModem(peripheralType)
  3. return peripheralType == "modem"
  4. end
  5.  
  6. -- Function to check if the computer is connected to a modem
  7. local function isModemConnected()
  8. local peripherals = peripheral.getNames()
  9. for _, pType in ipairs(peripherals) do
  10. if isModem(peripheral.getType(pType)) then
  11. return true
  12. end
  13. end
  14. return false
  15. end
  16.  
  17. -- Function to read network configuration
  18. local function readNetworkConfig()
  19. local configFile = "/disk/security/enterprise/network.config"
  20. local config = {}
  21.  
  22. -- Attempt to read the configuration file
  23. local file = fs.open(configFile, "r")
  24. if file then
  25. local data = file.readAll()
  26. file.close()
  27.  
  28. -- Assuming the config file contains a single line with "true" or "false"
  29. config.enabled = data:lower() == "true"
  30. else
  31. -- If the config file doesn't exist, default to disabled
  32. config.enabled = false
  33. end
  34.  
  35. return config
  36. end
  37.  
  38. -- Function to run /disk/boot/BIOS
  39. local function runBIOS()
  40. shell.run("/disk/boot/BIOS")
  41. end
  42.  
  43. -- Main program logic
  44. term.clear()
  45. term.setCursorPos(1, 1)
  46.  
  47. if not isModemConnected() then
  48. print("Failed to connect to LAN")
  49. else
  50. -- Check the network configuration
  51. local networkConfig = readNetworkConfig()
  52.  
  53. if networkConfig.enabled then
  54. -- Your code to run when network.config is true
  55. else
  56. -- Execute the boot animation command
  57. shell.run("/disk/boot/boot-animation")
  58.  
  59. -- Run /disk/boot/BIOS
  60. runBIOS()
  61.  
  62. -- Create the network.config file with a message
  63. local configFile = "/disk/security/enterprise/network.config"
  64. local file = fs.open(configFile, "w")
  65. if file then
  66. file.write("Network.config doesn't exist in enterprise patched device")
  67. file.close()
  68. else
  69. print("Failed to create network.config file")
  70. end
  71. end
  72. end
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement