redhat-set_hostname.sh: fix for F15+/RHEL7

New Fedora releases as well as RHEL7 uses systemd, which prefers
to take hostname from /etc/hostname (a la Debian), therefore if
this file is present, setting hostname in /etc/sysconfig/network
no longer works.

To fix, check if /etc/hostname exists and set hostname in there,
otherwise use old setup.

NOTE: hostname(5) says that hostname should not contain dots, i.e.
not be FQDN, so we strip the domain name out of it. This is in line
with what debian_set-hostname.sh is doing (see bug #1087 and/or
commit 57bfaa5).

https://bugzilla.openvz.org/3051

Reported-by: Stefan Eriksson <stefan_erikss0n@hotmail.com>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
1 file changed