diff --git a/bmotd.sh b/bmotd.sh index 9da1fc7..aabac50 100755 --- a/bmotd.sh +++ b/bmotd.sh @@ -78,7 +78,10 @@ update() { FQDN=$(hostname -f) OSID=$(cat /etc/*-release 2>/dev/null | awk -F'=' '/^ID=/ { print $2; count++ } END { if (!count) print "Unknown" }') KERNEL=$(uname -r) - EXTERNAL=$(dig TXT +time=3 +tries=2 +short o-o.myaddr.l.google.com @ns1.google.com | tr -d '"') + # check if crontab present + if command -v dig >/dev/null 2>&1; then + EXTERNAL=$(dig TXT +time=3 +tries=2 +short o-o.myaddr.l.google.com @ns1.google.com | tr -d '"') + fi # Check if pkg number cache exists test -f "$CACHEPATH/pkg_count" || PKG_REFRESH=1 @@ -283,7 +286,9 @@ motdGen() { echo -e " $C3║$C2 • Pkg to update......$C3: $C1 $PKG_NU" >> $MOTD echo -e " $C3║$C2 • Uptime,Load........$C3: $C1 $UPTIME_EXT" >> $MOTD echo -e " $C3║$C2 • Kernel.............$C3: $C1 $KERNEL" >> $MOTD - echo -e " $C3║$C2 • External IP........$C3: $C1 $EXTERNAL" >> $MOTD + if ! test -z $EXTERNAL; then + echo -e " $C3║$C2 • External IP........$C3: $C1 $EXTERNAL" >> $MOTD + fi for (( i=0; i<${#arr[@]}; i++ )); do if [ $i -eq 0 ]; then echo -e "$C3 ║$C2 • Network Interfaces.$C3: $C1 ${arr[$i]}" >> $MOTD