ommit external IP if dig not present

master
czoczo 7 years ago
parent e79a8a7235
commit 2335859263
  1. 5
      bmotd.sh

@ -78,7 +78,10 @@ update() {
FQDN=$(hostname -f) FQDN=$(hostname -f)
OSID=$(cat /etc/*-release 2>/dev/null | awk -F'=' '/^ID=/ { print $2; count++ } END { if (!count) print "Unknown" }') OSID=$(cat /etc/*-release 2>/dev/null | awk -F'=' '/^ID=/ { print $2; count++ } END { if (!count) print "Unknown" }')
KERNEL=$(uname -r) KERNEL=$(uname -r)
# 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 '"') 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 # Check if pkg number cache exists
test -f "$CACHEPATH/pkg_count" || PKG_REFRESH=1 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 • Pkg to update......$C3: $C1 $PKG_NU" >> $MOTD
echo -e " $C3$C2 • Uptime,Load........$C3: $C1 $UPTIME_EXT" >> $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 • Kernel.............$C3: $C1 $KERNEL" >> $MOTD
if ! test -z $EXTERNAL; then
echo -e " $C3$C2 • External IP........$C3: $C1 $EXTERNAL" >> $MOTD echo -e " $C3$C2 • External IP........$C3: $C1 $EXTERNAL" >> $MOTD
fi
for (( i=0; i<${#arr[@]}; i++ )); do for (( i=0; i<${#arr[@]}; i++ )); do
if [ $i -eq 0 ]; then if [ $i -eq 0 ]; then
echo -e "$C3$C2 • Network Interfaces.$C3: $C1 ${arr[$i]}" >> $MOTD echo -e "$C3$C2 • Network Interfaces.$C3: $C1 ${arr[$i]}" >> $MOTD

Loading…
Cancel
Save