Sh3ll



Directory :  /scripts2/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

Current File : //scripts2/notify_defaddr_conf.sh
#!/bin/bash
# Notify of undesirable cPanel Default Address settings for emails. Expected result is ":fail:".
# This script is DEPRECATED, it was authomatized with correct_defaddr.sh and list_defaddr_fwd.sh.

HOSTNAME=$(hostname)

EMAIL="sysadmin@sitioshispanos.com"

INFRACTORS=$(mktemp)

WANTED=":fail:"

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[].defaultaddress                                     |
  while read -r opt; do
    if [[ "$opt" =~ "$WANTED" ]]; then
      break
    fi
    echo "$acc" >> $INFRACTORS
  done
done

if [ -s "$INFRACTORS" ]; then
  cat $INFRACTORS | mail -s "Accounts with improper Default Address settings at $HOSTNAME" $EMAIL
fi

Sh3LL