mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
Added basic hostname mechanism to OpenOS
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
parent
61a40b9428
commit
9e4b29b4cf
@ -0,0 +1,14 @@
|
|||||||
|
local args = {...}
|
||||||
|
if args[1] then
|
||||||
|
local file = io.open("/etc/hostname", "w")
|
||||||
|
file:write(args[1])
|
||||||
|
file:close()
|
||||||
|
os.setenv("HOSTNAME", args[1])
|
||||||
|
os.setenv("PS1", "$HOSTNAME:$PWD# ")
|
||||||
|
else
|
||||||
|
local file = io.open("/etc/hostname")
|
||||||
|
if file then
|
||||||
|
io.write(file:read("*l"))
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
end
|
@ -14,3 +14,12 @@ shell.setAlias("view", "edit -r")
|
|||||||
shell.setAlias("help", "man")
|
shell.setAlias("help", "man")
|
||||||
shell.setAlias("?", "man")
|
shell.setAlias("?", "man")
|
||||||
shell.setAlias("cp", "cp -i")
|
shell.setAlias("cp", "cp -i")
|
||||||
|
|
||||||
|
event.listen("init", function()
|
||||||
|
local file = io.open("/etc/hostname")
|
||||||
|
if file then
|
||||||
|
os.setenv("HOSTNAME", file:read("*l"))
|
||||||
|
os.setenv("PS1", "$HOSTNAME:$PWD# ")
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user