[packages/systemd] setup /etc/hostname only if file is missing or empty

glen glen at pld-linux.org
Mon Jun 8 14:46:34 CEST 2015


commit c457212c65d13c3afb045f77f05f598d0ec5befe
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Mon Jun 8 15:44:29 2015 +0300

    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.
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/systemd.git/commitdiff/c457212c65d13c3afb045f77f05f598d0ec5befe



More information about the pld-cvs-commit mailing list