Blob Blame History Raw
diff --git a/sapconf b/sapconf
index 471620e..f65451a 100644
--- a/sapconf
+++ b/sapconf
@@ -463,11 +463,13 @@ dn=$(dnsdomainname)
 if [ -z "${dn}" ]; then
         ### This fails, if ip of $hs is unreachable or $hs unknown in nameservice
         ip=$(ping -q -c 1 -t 1 $hs | grep PING | sed -e "s/^[^(]*[(]//" | sed -e "s/[)].*$//")
-        [ ${ip} == "127.0.0.1" ] &&\
+        [ "${ip}" == "127.0.0.1" ] &&\
                 ip=$(ip addr show dev $( netstat -r | awk ' ( $1 == "default" ) { print $NF }')|awk '( $1 == "inet" ) { print $2 } ' | cut -d/ -f1)
-        dn=$(/usr/bin/host $ip  | cut -d' ' -f 5 | cut -d. -f 2-)
-        dn=$(echo ${dn%.})
-        hl=${hs}.${dn}
+        if [ -n "${ip}" ]; then
+                dn=$(/usr/bin/host $ip  | cut -d' ' -f 5 | cut -d. -f 2-)
+                dn=$(echo ${dn%.})
+                hl=${hs}.${dn}
+        fi
 fi
 
 ### No still no domainname is found DNS is not configured correctly
@@ -543,13 +545,13 @@ fi
 num_ip=$( grep "^${ip}" /etc/hosts | wc -l)
 
 ### Now if localhost is ok  and names are resolved correctly, assume /etc/host is ok. ####
-if [ $(hostname -f) == "${hl}" ] && [ $fix_localhost -eq 0 ] && [ $num_ip -eq 1 ]; then
+if [ "$(hostname -f)" == "${hl}" ] && [ $fix_localhost -eq 0 ] && [ $num_ip -eq 1 ]; then
          out "/etc/hosts ... OK"
 else
          out "/etc/hosts checking ... not OK"
 
          ####  if ip is localhost, get ip from primary interface, identified by the default route
-         [ ${ip} == "127.0.0.1" ] &&\
+         [ "${ip}" == "127.0.0.1" ] &&\
                 ip=$(ip addr show dev $( netstat -r | awk ' ( $1 == "default" ) { print $NF }')|awk '( $1 == "inet" ) { print $2 } ' | cut -d/ -f1)
 
          if [ $CHECK_ONLY == 0 ]; then