Quantcast
Channel: Zimbra Forums
Viewing all articles
Browse latest Browse all 1130

Administrators • Re: Listing domains

$
0
0
Here's a simple bash script to get the status for all local (not alias) domains, sorted alphabetically.

Hope that helps,
Mark

Code:

#!/bin/bash## Copyright 2024 Mission Critical Email, LLC.# All rights reserved, except, that you may use and modify this script# in your own Zimbra environment provided that any modification includes# all of the comment lines as is.# You may not republish or otherwise distribute this script to third parties.## Get the current date for the output filedate=$(date +"%Y-%m-%d")# Output fileoutput_file="/tmp/local-domain-status-$date.txt"# Initialize the output fileecho "Local domains with their statuses as of $date" > "$output_file"echo "----------------------------------------------" >> "$output_file"# Get the list of domains sorted alphabeticallyzmprov gad | sort | while read domain; do    # Display progress message on the screen    echo "Now fetching the domain status for $domain..."        # Get the domain type    domain_type=$(zmprov gd "$domain" zimbraDomainType | grep 'zimbraDomainType' | awk '{print $2}')        # Check if the domain type is local    if [ "$domain_type" == "local" ]; then        # Get the domain status        domain_status=$(zmprov gd "$domain" zimbraDomainStatus | grep 'zimbraDomainStatus' | awk '{print $2}')                # Append the domain and its status to the output file (whether active or not)        echo "$domain - $domain_status" >> "$output_file"    fidoneecho "All done! Local domains and their statuses have been saved to $output_file."

Statistics: Posted by L. Mark Stone — Tue Sep 17, 2024 2:19 pm



Viewing all articles
Browse latest Browse all 1130

Trending Articles