[Lunar-commits] <lunar-tools> Use hostnamectl for systemd.

Peter de Ridder peter at lunar-linux.org
Sun Jun 2 18:35:26 CEST 2013


commit f00b1040c832af8d8b06ca3dc7c35e5ed8c0233a
Author: Peter de Ridder <peter at lunar-linux.org>
Date: Sun, 02 Jun 2013 07:54:04 -0700
URL: https://github.com/lunar-linux/lunar-tools/commit/f00b1040c832af8d8b06ca3dc7c35e5ed8c0233a

Use hostnamectl for systemd.
---
  prog/lnet | +22/-16   
  1 file changed, 22 insertions(+), 16 deletions(-)

--- a/prog/lnet
+++ b/prog/lnet
@@ -217,24 +217,30 @@ function hostname_config()
      HOSTNAME=$(cat /etc/hostname)
    fi
    HOSTNAME=`inputbox "Enter this systems host name" "$HOSTNAME"`
-   if [ -n "$HOSTNAME" ]; then
-     echo "$HOSTNAME" > /etc/hostname
-   else
-     rm /etc/hostname
-   fi
-   if [ -f /etc/domainname ]; then
-     DOMAINNAME=$(cat /etc/domainname)
-   fi
-   DOMAINNAME=`inputbox "Enter this systems domain name" "$DOMAINNAME"`
-   if [ -n "$DOMAINNAME" ]; then
-     echo "$DOMAINNAME" > /etc/domainname
+   # Assume systemd is running
+   if [ -n "$SYSTEMDUNITDIR" ]; then
+     clear
+     hostnamectl set-hostname "$HOSTNAME"
    else
-     rm /etc/domainname
+     if [ -n "$HOSTNAME" ]; then
+       echo "$HOSTNAME" > /etc/hostname
+     else
+       rm /etc/hostname
+     fi
+     if [ -f /etc/domainname ]; then
+       DOMAINNAME=$(cat /etc/domainname)
+     fi
+     DOMAINNAME=`inputbox "Enter this systems domain name" "$DOMAINNAME"`
+     if [ -n "$DOMAINNAME" ]; then
+       echo "$DOMAINNAME" > /etc/domainname
+     else
+       rm /etc/domainname
+     fi
+  
+     # and set them too:
+     clear
+     /etc/init.d/hostname
    fi
-
-   # and set them too:
-   clear
-   /etc/init.d/hostname
    sleep 2
 }
 




More information about the Lunar-commits mailing list