SHOW:
|
|
- or go back to the newest paste.
| 1 | - | network = require("network") |
| 1 | + | network = require("network")
|
| 2 | - | event = require("event") |
| 2 | + | event = require("event")
|
| 3 | - | fs = require("filesystem") |
| 3 | + | fs = require("filesystem")
|
| 4 | - | |
| 4 | + | |
| 5 | - | function start() |
| 5 | + | function start() |
| 6 | - | f = io.open("/etc/hostname") |
| 6 | + | os.sleep(0.5) |
| 7 | - | name = f:read() |
| 7 | + | f = io.open("/etc/hostname")
|
| 8 | - | f:close() |
| 8 | + | name = f:read() |
| 9 | - | network.ip.bind(name) |
| 9 | + | f:close() |
| 10 | - | print("Binding to hostname: "..name) |
| 10 | + | network.ip.bind(name) |
| 11 | print("Binding to hostname: "..name)
| |
| 12 | - | |
| 12 | + | end |
| 13 | - | if fs.exists("/etc/hostname") then |
| 13 | + | |
| 14 | - | event.listen("network_ready", start) |
| 14 | + | if fs.exists("/etc/hostname") then
|
| 15 | event.listen("init", start)
| |
| 16 | end |