[__hostname] Add support for Gentoo

This commit is contained in:
Dennis Camera 2019-10-06 23:34:59 +02:00
parent 064e992a7a
commit c11e757dfa
3 changed files with 15 additions and 5 deletions

View file

@ -41,6 +41,9 @@ in
freebsd)
(. /etc/rc.conf && echo "$hostname")
;;
gentoo)
(. /etc/conf.d/hostname && echo "$hostname")
;;
macosx)
scutil --get HostName 2>/dev/null
;;

View file

@ -74,14 +74,10 @@ fi
# Use the good old way to set the hostname. Also if hostnamectl fails.
case $os
in
archlinux|debian|ubuntu|devuan|coreos|alpine)
alpine|archlinux|coreos|debian|devuan|ubuntu)
echo "printf '%s\\n' '$name_should' > /etc/hostname"
echo "hostname -F /etc/hostname"
;;
centos|fedora|redhat|scientific|freebsd|openbsd)
# NOTE: Writing the hostname to file is done in the manifest.
echo "hostname '$name_should'"
;;
macosx)
echo "scutil --set HostName '$name_should'"
;;
@ -91,6 +87,10 @@ in
echo "printf '%s\\n' '$name_should' > /etc/HOSTNAME"
echo 'hostname -F /etc/HOSTNAME'
;;
centos|fedora|freebsd|gentoo|netbsd|openbsd|redhat|scientific)
# NOTE: Writing the hostname to file is done in the manifest.
echo "hostname '$name_should'"
;;
*)
echo "echo 'Unsupported OS: $os' >&2; exit 1"
;;

View file

@ -58,6 +58,13 @@ in
--key HOSTNAME \
--value "\"$name_should\""
;;
gentoo)
__key_value confd-hostname \
--file /etc/conf.d/hostname \
--delimiter '=' --exact_delimiter \
--key 'hostname' \
--value "\"$name_should\""
;;
freebsd)
__key_value rcconf-hostname \
--file /etc/rc.conf \