View Single Post
  #4 (permalink)  
Old 04-30-2009, 02:02 PM
gregg1ep00 gregg1ep00 is offline
Junior Member
 
Posts: 5
Default Missing Script

My original post has disappeared, so here is the script:

Code:
#!/bin/bash

# This is a script to go through all users of a domain
# and set the zimbraDataSourcePollingInterval attribute
# for all external accounts to the specified value.

# $1 = domain name
# $2 = polling interval in seconds

# Default Settings
DEFAULT_INTERVAL=60    # Default polling interval is 60 seconds

# Return codes
S_OK=0
E_WRONGARGS=85        # Wrong arguments


USAGE="Usage: `basename ${0}` -d domain-name [-i interval]"
INTERVAL=${DEFAULT_INTERVAL}

# ------- Begin Script -------

# Parse command-line arguments
while [ $# -gt 0 ]; do
    case "${1}" in
        -d|--domain)
            DOMAIN=${2}
            shift
            ;;

        -i|--interval)
            INTERVAL=${2}
            shift
            ;;

        *)
            echo "${USAGE}"
            exit ${E_WRONGARGS}
    esac

    shift                # Check next set of parameters
done

# Make sure we have the domain name
if [ -z "${DOMAIN}" ]
then
    echo "${USAGE}"
    exit ${E_WRONGARGS}
fi

# Make sure there are no .ds files
rm -f *.ds

# Make sure the commands.zmprov file is gone
if [ -e commands.zmprov ]
then
    rm -f commands.zmprov
fi

echo "Processing intervals for domain ${DOMAIN} - setting interval to ${INTERVAL}..."

# Loop through all accounts in domain
for ACCOUNT in `zmprov gaa ${DOMAIN}`
do
    echo "Searching account ${ACCOUNT}..."

    # Create a list of data source names for this account
    zmprov gds ${ACCOUNT} | grep zimbraDataSourceId | awk -F': ' '{print $2}' > ${ACCOUNT}.ds

    # Loop through all data source names and set the interval
    for DSID in `cat ${ACCOUNT}.ds`
    do
        echo "Found data source ${DSID}..."

        # Set the interval
        echo "mds ${ACCOUNT} ${DSID} zimbraDataSourcePollingInterval ${INTERVAL}" >> commands.zmprov
    done

    # When we're finished with the data source file, remove it
    rm -f ${ACCOUNT}.ds
done

# Run the commands
if [ -e commands.zmprov ]
then
    echo "Running zmprov..."
    cat commands.zmprov
else
    echo "Nothing to do!"
fi

zmprov < commands.zmprov

# Delete the file
rm -f commands.zmprov

# All is well, exit here
exit ${S_OK}
# ------- End Script -------
__________________
Release 5.0.15_GA_2851.UBUNTU8 UBUNTU8 NETWORK edition
Ubuntu 8.04 LTS x86
Reply With Quote