X-Git-Url: http://git.grml.org/?a=blobdiff_plain;ds=sidebyside;f=usr_sbin%2Fgrml-hostname;h=b7a6eab8667424bc23c8b97f2a04c07143b6282b;hb=2706049698b8bc7478aa252f5e3a4f394bad4e5e;hp=e97c3535580d1d5c3c2a8fafe7d6faec94db7742;hpb=3ea7b7562e8e55bc5a1d81b561d494266e5f9845;p=grml-scripts.git diff --git a/usr_sbin/grml-hostname b/usr_sbin/grml-hostname index e97c353..b7a6eab 100755 --- a/usr_sbin/grml-hostname +++ b/usr_sbin/grml-hostname @@ -37,6 +37,20 @@ else retval=0 fi +# stupid + simplified checking for valid hostname (according to RFC 952) +VALIDATE=$(echo "$NEW_HOSTNAME" | tr --delete '[:alnum:]-') +if [ -n "$VALIDATE" ] ; then + if [ -z "$NONINTERACTIVE" ] ; then + dialog --title "${PN}" \ + --msgbox "Error: invalid characters specified in hostname: '$VALIDATE' can not be used inside hostnames." \ + 0 0 + exec "$0" + else + echo "Error: invalid characters specified in hostname: '$VALIDATE' can not be used inside hostnames." >&2 + exit 1 + fi +fi + case $retval in 0) echo "$NEW_HOSTNAME" > /etc/hostname @@ -57,6 +71,10 @@ Configuration of myhostname in /etc/postfix/main.cf has been adjusted as well. D fi fi + if [ -x /etc/init.d/avahi-daemon ] && pgrep avahi-daemon >/dev/null ; then + /etc/init.d/avahi-daemon restart + fi + /etc/init.d/hostname.sh if [ -z "$NONINTERACTIVE" ] ; then