X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_sbin%2Fgrml-hostname;h=e97c3535580d1d5c3c2a8fafe7d6faec94db7742;hb=3ea7b7562e8e55bc5a1d81b561d494266e5f9845;hp=d512823da68414b2d2c9486169d81f65ef462ab9;hpb=d4dcda87d0db4d06af5ea3d1abd44bbb5823f754;p=grml-scripts.git diff --git a/usr_sbin/grml-hostname b/usr_sbin/grml-hostname index d512823..e97c353 100755 --- a/usr_sbin/grml-hostname +++ b/usr_sbin/grml-hostname @@ -41,14 +41,16 @@ case $retval in 0) 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 + sed -ir "s/^\(127.0.0.1\s*\).*localhost.*/\1$NEW_HOSTNAME localhost/" /etc/hosts + sed -ir "s/^\(::1\s*\).*ip6-localhost.*/\1ip6-localhost ip6-loopback $NEW_HOSTNAME/" /etc/hosts + POSTFIX='' if [ -r /etc/postfix/main.cf ] ; then 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 [ -n "$DISPLAY" ] ; then if sudo -u $RUNASUSER xauth add $(xauth -n list | grep "${OLDHOSTNAME}/unix:0" | sed "s|${OLDHOSTNAME}/unix:0|${NEW_HOSTNAME}/unix:0|") ; then sudo -u $RUNASUSER xauth remove "${OLDHOSTNAME}/unix:0"