From c457212c65d13c3afb045f77f05f598d0ec5befe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 8 Jun 2015 15:44:29 +0300 Subject: [PATCH] setup /etc/hostname only if file is missing or empty http://lists.pld-linux.org/mailman/pipermail/pld-devel-en/2015-June/024391.html --- systemd.spec | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/systemd.spec b/systemd.spec index 7f2c20a..de0f970 100644 --- a/systemd.spec +++ b/systemd.spec @@ -934,13 +934,14 @@ if [ $1 -eq 1 ]; then # And symlink what we found to the new-style default.target ln -s "$target" %{_sysconfdir}/systemd/system/default.target || : - # Setup hostname - HOSTNAME= - [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network - if [ -n "$HOSTNAME" -a "$HOSTNAME" != "pldmachine" ]; then - [ -f /etc/hostname ] && mv -f /etc/hostname /etc/hostname.rpmsave - echo $HOSTNAME > /etc/hostname - chmod 644 /etc/hostname + # Setup hostname if not yet done so + if [ ! -f /etc/hostname ] || [ ! -s /etc/hostname ]; then + HOSTNAME= + [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network + if [ -n "$HOSTNAME" -a "$HOSTNAME" != "pldmachine" ]; then + echo $HOSTNAME > /etc/hostname + chmod 644 /etc/hostname + fi fi # Enable the services we install by default. -- 2.44.0