Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to check if a peripheral is a modem
- local function isModem(peripheralType)
- return peripheralType == "modem"
- end
- -- Function to check if the computer is connected to a modem
- local function isModemConnected()
- local peripherals = peripheral.getNames()
- for _, pType in ipairs(peripherals) do
- if isModem(peripheral.getType(pType)) then
- return true
- end
- end
- return false
- end
- -- Function to read network configuration
- local function readNetworkConfig()
- local configFile = "/disk/security/enterprise/network.config"
- local config = {}
- -- Attempt to read the configuration file
- local file = fs.open(configFile, "r")
- if file then
- local data = file.readAll()
- file.close()
- -- Assuming the config file contains a single line with "true" or "false"
- config.enabled = data:lower() == "true"
- else
- -- If the config file doesn't exist, default to disabled
- config.enabled = false
- end
- return config
- end
- -- Function to run /disk/boot/BIOS
- local function runBIOS()
- shell.run("/disk/boot/BIOS")
- end
- -- Main program logic
- term.clear()
- term.setCursorPos(1, 1)
- if not isModemConnected() then
- print("Failed to connect to LAN")
- else
- -- Check the network configuration
- local networkConfig = readNetworkConfig()
- if networkConfig.enabled then
- -- Your code to run when network.config is true
- else
- -- Execute the boot animation command
- shell.run("/disk/boot/boot-animation")
- -- Run /disk/boot/BIOS
- runBIOS()
- -- Create the network.config file with a message
- local configFile = "/disk/security/enterprise/network.config"
- local file = fs.open(configFile, "w")
- if file then
- file.write("Network.config doesn't exist in enterprise patched device")
- file.close()
- else
- print("Failed to create network.config file")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement