From b3aa15b5804f0a32360e6f1d0d0fce13e66cd34f Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 19 Nov 2019 21:38:22 +1100 Subject: [PATCH] init now sets the hostname, if possible --- exec/init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/exec/init.lua b/exec/init.lua index 897240d..42d3cab 100644 --- a/exec/init.lua +++ b/exec/init.lua @@ -4,6 +4,14 @@ end os.setenv("PWD","/boot") io.input("/dev/null") io.output("/dev/syslog") +local f = io.open("/boot/cfg/hostname","rb") +local hostname = computer.address():sub(1,8) +if f then + hostname = f:read("*l") + f:close() +end +os.setenv("HOSTNAME",hostname) +syslog(string.format("Hostname set to %s",hostname)) local pids = {} local function loadlist() local f = io.open("/boot/cfg/init.txt","rb")