]> git.pld-linux.org Git - packages/systemd.git/commitdiff
setup /etc/hostname only if file is missing or empty
authorElan Ruusamäe <glen@delfi.ee>
Mon, 8 Jun 2015 12:44:29 +0000 (15:44 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Mon, 8 Jun 2015 12:46:23 +0000 (15:46 +0300)
http://lists.pld-linux.org/mailman/pipermail/pld-devel-en/2015-June/024391.html

systemd.spec

index 7f2c20a11d90fe8fb644e22c61ad2b444413bac6..de0f9708fb126d82df45860cdd47483ada9cd667 100644 (file)
@@ -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.
This page took 0.865844 seconds and 4 git commands to generate.