TYPE-0
FILEMANAGER
UP LEVEL
HOME
EXIT
Current Directory:
scripts2
/
EDIT: correct_defaddr.sh
#!/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:" 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" =~ "$DEFADDR_FAIL" ]]; then break fi echo "$acc $opt" >> $INFRACTORS done done { while read acc dom defaddr do # Server notifications account. if [ "$acc" == "sitios" ]; then continue fi if [ "$defaddr" == "$acc" ]; then mode="DEFAULT" elif [ "$defaddr" =~ "$DEFADDR_BLACKHOLE" ]; then mode="BLACKHOLE" else mode="FWD_PIPE" fi if ! [ "$mode" == "FWP_PIPE" ]; then echo -n "$acc $dom $mode " uapi --output=json \ --user="$acc" \ Email \ set_default_address \ fwdopt='fail' \ domain="$dom" | jq -r .result.errors fi done } < "$INFRACTORS"
SAVE CHANGES
BACK TO DIR
TYPE-0 MANAGER © 2026 |
System Ready