From e429fbd4abb71d096dd584dfe87eff0edce086b1 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Thu, 24 Jul 2014 18:06:41 +0200 Subject: [PATCH] mambawelcome: fix configuring domain with hostnamectl (pass HOSTNAME.DOMAIN as 'hostnamectl set-hostname' option) --- mambawelcome/mambawelcome.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mambawelcome/mambawelcome.sh b/mambawelcome/mambawelcome.sh index cdfd22e..ab8c857 100755 --- a/mambawelcome/mambawelcome.sh +++ b/mambawelcome/mambawelcome.sh @@ -149,13 +149,15 @@ sh -c "echo $INSTALL_ROOT_PASSWORD | passwd --stdin" || { # set hostname and domain [[ "$INSTALL_HOSTNAME" ]] && { - hostnamectl set-hostname $INSTALL_HOSTNAME - sed -i "s|HOSTNAME=.*|HOSTNAME=$INSTALL_HOSTNAME|" \ - /etc/sysconfig/network - - [[ "$INSTALL_DOMAIN" ]] || INSTALL_DOMAIN="localdomain" - sed -i "s|\(127\.0\.0\.1\W*\)\(.*\)|\1 $INSTALL_HOSTNAME.$INSTALL_DOMAIN $INSTALL_HOSTNAME localhost.localdomain localhost|" \ - /etc/hosts + if [ "${INSTALL_HOSTNAME/.*}" != "${INSTALL_HOSTNAME}" -o "${INSTALL_DOMAIN}" = "localdomain" ]; then + hostnamectl set-hostname $INSTALL_HOSTNAME + if [ "${INSTALL_DOMAIN}" != "localdomain" ]; then + sed -i "s|\(127\.0\.0\.1\W*\)\(.*\)|\1 $INSTALL_HOSTNAME.$INSTALL_DOMAIN $INSTALL_HOSTNAME localhost.localdomain localhost|" \ + /etc/hosts + fi + elif [ "${INSTALL_DOMAIN}" != "localdomain" ]; then + hostnamectl set-hostname $INSTALL_HOSTNAME.$INSTALL_DOMAIN + fi } # set samba configuration file