Sh3ll



Directory :  /scripts2/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

Current File : //scripts2/list_defaddr_fwd.sh
#!/bin/bash
# Notify of undesirable cPanel Default Address settings for emails. Expected result is ":fail:".

HOSTNAME=$(hostname)

EMAIL="sysadmin@sitioshispanos.com"

INFRACTORS=$(mktemp)

WANTED=":fail:"

if [ "$HOSTNAME" == "dns.webhosting-network-services.com" ]; then
  echo "This is the DNS server. SKIP."
  exit 1
fi

whmapi1 --output=jsonpretty listaccts |
jq -r .data.acct[].user               |
while read -r acc; do
  uapi --output=json --user="$acc" Email list_default_address user="$acc" |
  jq -r '.result.data[] | "\(.domain) \(.defaultaddress)"'                |
  while read -r opt; do
    if [[ "$opt" =~ "$WANTED" ]]; then
      break
    fi
    echo "$acc $opt" >> $INFRACTORS
  done
done

{ while read acc dom defaddr
  do
    if [ "$acc" == "sitios" ]; then
      continue
    fi

    if [ "$defaddr" == "$acc" ]; then
      mode="DEFAULT"
    elif [ "$defaddr" =~ "\":blackhole:\"" ]; then
      mode="BLACKHOLE"
    else
      mode="FORWARD"
    fi

    if [ "$mode" == "FORWARD" ]; then
      echo "$acc: $dom -> $defaddr"
    fi
  done
} < "$INFRACTORS"


Sh3LL