Difference between revisions of "Automation: how to change all users's individual signatures"

(Zimbra Automation)
(How to change users's individual signatures based on their ldap attributes globally)
Line 7: Line 7:
  
 
== How to change users's individual signatures based on their ldap attributes globally ==
 
== How to change users's individual signatures based on their ldap attributes globally ==
 +
 +
 +
==Purpose==
 +
 +
The purpose of this article is to show how to create a simple script which, can modify every user's signature globally, based on their ldap attribute values in ldap.
 +
 +
==Resolution==
 +
 +
For the purpose we will use two scripts. In the process I will explain why combining the two scripts into one will not work.
 +
 +
Script 1
 +
<pre style="white-space: pre-wrap;
 +
white-space: -moz-pre-wrap;
 +
white-space: -pre-wrap;
 +
white-space: -o-pre-wrap;
 +
word-wrap: break-word;">
 +
#!/bin/bash
 +
 
 +
path="/opt/zimbra/bin"
 +
 
 +
    for i in `/opt/zimbra/bin/zmprov -l gaa` 
 +
      do
 +
      echo -ne "Checking account: $i \t"
 +
      $path/zmprov ma $i zimbraPrefMailSignatureEnabled TRUE
 +
     
 +
      signature=`$path/zmprov ga $i | egrep "(^cn|^ou|^company|^street|^telephoneNumber|^mobile|^title)" | cut -d : -f 2 | sed 's/^\ //g'`
 +
      $path/zmprov ma $i zimbraPrefMailSignatureEnabled TRUE zimbraPrefMailSignature "$signature"
 +
     
 +
      echo "done!"
 +
 +
    done
 +
</pre>
 +
 +
 +
Script 2
 +
 +
#!/bin/bash
 +
 
 +
  path="/opt/zimbra/bin"
 +
 
 +
    for i in `/opt/zimbra/bin/zmprov -l gaa` 
 +
    do
 +
      echo -ne "Adding SignatureID to account: $i \t"
 +
 +
      signatureid=`$path/zmprov ga $i zimbraSignatureId | sed -n '2p' | cut -d : -f 2 | sed 's/^\ //g'`
 +
      $path/zmprov ma $i zimbraPrefDefaultSignatureId "$signatureid"
 +
      $path/zmprov ma $i zimbraPrefForwardReplySignatureId "$signatureid"
 +
      echo "done!"
 +
    done

Revision as of 21:27, 25 September 2015

Zimbra Automation

   KB 22354        Last updated on 2015-09-25  




5.00
(one vote)


Zimbra automation using scripting.


How to change users's individual signatures based on their ldap attributes globally

Purpose

The purpose of this article is to show how to create a simple script which, can modify every user's signature globally, based on their ldap attribute values in ldap.

Resolution

For the purpose we will use two scripts. In the process I will explain why combining the two scripts into one will not work.

Script 1

#!/bin/bash
  
path="/opt/zimbra/bin"
  
     for i in `/opt/zimbra/bin/zmprov -l gaa`  
      do
       echo -ne "Checking account: $i \t"
       $path/zmprov ma $i zimbraPrefMailSignatureEnabled TRUE
       
       signature=`$path/zmprov ga $i | egrep "(^cn|^ou|^company|^street|^telephoneNumber|^mobile|^title)" | cut -d : -f 2 | sed 's/^\ //g'`
       $path/zmprov ma $i zimbraPrefMailSignatureEnabled TRUE zimbraPrefMailSignature "$signature"
       
       echo "done!"

    done


Script 2

  1. !/bin/bash
 path="/opt/zimbra/bin"
 
   for i in `/opt/zimbra/bin/zmprov -l gaa`  
    do
      echo -ne "Adding SignatureID to account: $i \t"
      signatureid=`$path/zmprov ga $i zimbraSignatureId | sed -n '2p' | cut -d : -f 2 | sed 's/^\ //g'`
      $path/zmprov ma $i zimbraPrefDefaultSignatureId "$signatureid"
      $path/zmprov ma $i zimbraPrefForwardReplySignatureId "$signatureid"
     echo "done!"
    done
Jump to: navigation, search