[__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) freebsd)
(. /etc/rc.conf && echo "$hostname") (. /etc/rc.conf && echo "$hostname")
;; ;;
gentoo)
(. /etc/conf.d/hostname && echo "$hostname")
;;
macosx) macosx)
scutil --get HostName 2>/dev/null 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. # Use the good old way to set the hostname. Also if hostnamectl fails.
case $os case $os
in in
archlinux|debian|ubuntu|devuan|coreos|alpine) alpine|archlinux|coreos|debian|devuan|ubuntu)
echo "printf '%s\\n' '$name_should' > /etc/hostname" echo "printf '%s\\n' '$name_should' > /etc/hostname"
echo "hostname -F /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) macosx)
echo "scutil --set HostName '$name_should'" echo "scutil --set HostName '$name_should'"
;; ;;
@ -91,6 +87,10 @@ in
echo "printf '%s\\n' '$name_should' > /etc/HOSTNAME" echo "printf '%s\\n' '$name_should' > /etc/HOSTNAME"
echo 'hostname -F /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" echo "echo 'Unsupported OS: $os' >&2; exit 1"
;; ;;

View file

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