Skip to content

Instantly share code, notes, and snippets.

@mankuthimma
Created October 19, 2011 08:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mankuthimma/1297767 to your computer and use it in GitHub Desktop.
Save mankuthimma/1297767 to your computer and use it in GitHub Desktop.
Shell script to sync all users in a zimbra domain to an org wide distribution list
#!/bin/bash
CURALL=`tempfile`
EMALL=`tempfile`
DIFFY=`tempfile`
ADDLIST=`tempfile`
zmprov -l gaa | sort | uniq > $EMALL
zmprov gdl all@example.com|grep "zimbraMailForwardingAddress:"|sed "s/zimbraMailForwardingAddress: //"|sort|uniq > $CURALL
diff --left-column $CURALL $EMALL | grep example.com | sed "s/> //g" > $DIFFY
diff /opt/zimbra/conf/all_list_ignore $DIFFY|grep example.com|sed "s/<//g"|sed "s/>//g"|sed "s/ //g" > $ADDLIST
echo "Adding members to all list"
cat $ADDLIST
while read l
do
zmprov adlm all@example.com $l
done < $ADDLIST
rm $EMALL $CURALL $DIFFY $ADDLIST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment