Remove all bashisms; drop grml-muttng
[grml-scripts-core.git] / usr_sbin / grml-hostname
index 96d4a51..1c958a0 100755 (executable)
@@ -4,7 +4,6 @@
 # Authors:       (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest Change: Thu Jan 29 15:56:54 CET 2009
 ################################################################################
 
 . /etc/grml/script-functions
@@ -17,20 +16,20 @@ OLDHOSTNAME="$(hostname)"
 case "$1" in -h|--help) echo "Usage: $0 [hostname]">&2; exit 1 ;; esac
 
 if [ -n "$1" ] ; then
-   HOSTNAME="$1"
+   NEW_HOSTNAME="$1"
    NONINTERACTIVE=1
 else
    if [ -x /usr/bin/random-hostname ] ; then
-      HOSTNAME="$(/usr/bin/random-hostname)"
+      NEW_HOSTNAME="$(/usr/bin/random-hostname)"
    else
-      HOSTNAME="$(hostname)"
+      NEW_HOSTNAME="$(hostname)"
    fi
 fi
 
 if [ -z "$NONINTERACTIVE" ] ; then
-   HOSTNAME="$(dialog --stdout --title "${PN}" --extra-button --extra-label "Propose hostname" \
+   NEW_HOSTNAME="$(dialog --stdout --title "${PN}" --extra-button --extra-label "Propose hostname" \
    --inputbox "Set hostname (/etc/hostname, /etc/hosts and /etc/postfix/main.cf will be adjusted)\
-\n\nTip: press 'Propose hostname' for another proposal" 14 70 $HOSTNAME)"
+\n\nTip: press 'Propose hostname' for another proposal" 14 70 $NEW_HOSTNAME)"
   retval=$?
 else
   retval=0
@@ -38,20 +37,20 @@ fi
 
 case $retval in
   0)
-     echo "$HOSTNAME" > /etc/hostname
-     echo "$HOSTNAME" > /etc/mailname
-     sed -i "s/^127.0.0.1[ \t]*$OLDHOSTNAME[ \t]*localhost/127.0.0.1       $HOSTNAME localhost/" /etc/hosts
-     sed -i "s/^::1[ \t]*ip6-localhost ip6-loopback[ \t]*$OLDHOSTNAME/::1     ip6-localhost ip6-loopback $HOSTNAME/" /etc/hosts
+     echo "$NEW_HOSTNAME" > /etc/hostname
+     echo "$NEW_HOSTNAME" > /etc/mailname
+     sed -i "s/^127.0.0.1[ \t]*$OLDHOSTNAME[ \t]*localhost/127.0.0.1       $NEW_HOSTNAME localhost/" /etc/hosts
+     sed -i "s/^::1[ \t]*ip6-localhost ip6-loopback[ \t]*$OLDHOSTNAME/::1     ip6-localhost ip6-loopback $NEW_HOSTNAME/" /etc/hosts
      POSTFIX=''
      if [ -r /etc/postfix/main.cf ] ; then
-       sed -i "s/^mydestination = .*/mydestination = $HOSTNAME, localhost, localhost.localdomain/" /etc/postfix/main.cf && \
-       sed -i "s/^myhostname = .*/myhostname = $HOSTNAME/" /etc/postfix/main.cf && POSTFIX='
+       sed -i "s/^mydestination = .*/mydestination = $NEW_HOSTNAME, localhost, localhost.localdomain/" /etc/postfix/main.cf && \
+       sed -i "s/^myhostname = .*/myhostname = $NEW_HOSTNAME/" /etc/postfix/main.cf && POSTFIX='
 Configuration of myhostname in /etc/postfix/main.cf has been adjusted as well. Do not forget to restart postfix if necessary.'
      fi
      if [ -z "$NONINTERACTIVE" ] ; then
-        dialog --stdout --title "${PN}" --msgbox "Setting hostname to $HOSTNAME was successful.$POSTFIX" 0 0
+        dialog --stdout --title "${PN}" --msgbox "Setting hostname to $NEW_HOSTNAME was successful.$POSTFIX" 0 0
      else
-        echo "Setting hostname to $HOSTNAME: done"
+        echo "Setting hostname to $NEW_HOSTNAME: done"
      fi
      exit 0
      ;;