[__hostname] Add support for NetBSD

This commit is contained in:
Dennis Camera 2019-10-05 20:10:52 +02:00
parent 1bab641c94
commit d43eb5b22f
2 changed files with 19 additions and 0 deletions

View File

@ -43,6 +43,16 @@ in
freebsd)
(. /etc/rc.conf && echo "$hostname")
;;
netbsd)
if grep -q '^hostname=' /etc/rc.conf
then
(. /etc/rc.conf && echo "$hostname")
elif [ -f /etc/myname ]
then
# Fall back to /etc/myname file
cat /etc/myname
fi
;;
openbsd)
cat /etc/myname
;;

View File

@ -60,6 +60,15 @@ case "$os" in
--key 'hostname' \
--value "$name_should"
;;
netbsd)
__key_value rcconf-hostname \
--file /etc/rc.conf \
--delimiter '=' \
--key 'hostname' \
--value "\"$name_should\""
# To avoid confusion, ensure that the hostname is only stored once
__file /etc/myname --state absent
;;
openbsd)
echo "$name_should" | __file /etc/myname --source -
;;