No longer execute hostname command if hostname option is not present
authorMichael Prokop <mika@grml.org>
Fri, 22 Jun 2012 20:32:00 +0000 (22:32 +0200)
committerMichael Prokop <mika@grml.org>
Fri, 22 Jun 2012 20:32:00 +0000 (22:32 +0200)
There's no need to execute the hostname command if the boot
option hostname is not present as /etc/init.d/hostname.sh is
executed on Grml during bootup. We keep the config_hostname()
only because we support setting it to a random hostname if no
argument was specified to the boot option and to keep using
grml-hostname as main interface for changing hostnames
on-the-fly.

autoconfig.functions

index 8eba860..035803d 100755 (executable)
@@ -372,20 +372,21 @@ config_language(){
 
 # {{{ Set hostname
 config_hostname(){
 
 # {{{ Set hostname
 config_hostname(){
- if checkbootparam 'hostname' ; then
+  if ! checkbootparam 'hostname' ; then
+    return 0
+  fi
+
   HOSTNAME="$(getbootparam 'hostname' 2>>$DEBUG)"
   if [ -z "$HOSTNAME" ] && [ -x /usr/bin/random-hostname ] ; then
   HOSTNAME="$(getbootparam 'hostname' 2>>$DEBUG)"
   if [ -z "$HOSTNAME" ] && [ -x /usr/bin/random-hostname ] ; then
-     einfo "Generating random hostname as no hostname was specified."
-     HOSTNAME="$(/usr/bin/random-hostname)"
-     eend $?
+    einfo "Generating random hostname as no hostname was specified."
+    HOSTNAME="$(/usr/bin/random-hostname)"
+    eend $?
   fi
   fi
+
   einfo "Setting hostname to $HOSTNAME as requested."
   einfo "Setting hostname to $HOSTNAME as requested."
-  grml-hostname $HOSTNAME >>$DEBUG ; RC=$?
-  [ "$RC" = "0" ] && hostname $HOSTNAME
+  grml-hostname $HOSTNAME >>$DEBUG ; eend $RC
   eend $RC
   eend $RC
- else
-  hostname --file /etc/hostname
- fi
+fi
 }
 # }}}
 
 }
 # }}}