|
Directory : /scripts2/ |
#!/bin/bash
# Correct undesirable cPanel Default Address settings for emails for all cPanel accounts.
# Expected result is ":fail:".
HOSTNAME=$(hostname)
EMAIL="sysadmin@sitioshispanos.com"
INFRACTORS=$(mktemp)
#DEFADDR_FAIL=":fail:"
#DEFADDR_BLACKHOLE=":blackhole:"
HAS_GMAIL="gmail"
HAS_HOTMAIL="hotmail"
echo $HOSTNAME >> $INFRACTORS
echo "---" >> $INFRACTORS
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" =~ "$HAS_HOTMAIL" ]]; then
echo "$acc $opt" >> $INFRACTORS
elif [[ "$opt" =~ "$HAS_GMAIL" ]]; then
echo "$acc $opt" >> $INFRACTORS
fi
done
done
cat $INFRACTORS
echo ""