Home Gw Manage Signatures In A Workspace With Gamadv Xtd3
Post
Cancel

Gw Manage Signatures In A Workspace With Gamadv Xtd3

Who is this for?

For GW admins, who would like to automatically manage all of your stuff signatures in Google Workspace, without paying for some obscure 3rd party tool.

How is this done?

With open-source tool GAMADV-XTD3.

If you don’t know what GAM and GAMADV-XTD3

Check out my previous post where I explained everything about GAMADV-XTD3

Disclaimer

This was already done by some gentleman whos name I wasnt able to find. The tutorial was just a little old, confusing and few things needed to be changed. Original post

How to

First we need to create a custom signature template

You can either create your own or download it. There are plenty of sites just for this.

I’ll be using mine

Create working directory

1
2
mkdir -p /root/scripts/update_signatures/
cd /root/scripts/update_signatures/
1
vim /root/scripts/update_signatures/signature_template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<div dir="ltr">
  <div style="margin: 8px 0px 0px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;Google Sans&quot;, Roboto, RobotoDraft, Helvetica, Arial, sans-serif;">
    <div>
      <div dir="ltr">
        <font color="#888888">
          <div dir="ltr">
            <div dir="ltr">
              <div style="margin: 8px 0px 0px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;Google Sans&quot;, Roboto, RobotoDraft, Helvetica, Arial, sans-serif;">
                <div>
                  <div dir="ltr">
                    <font color="#888888">
                      <div dir="ltr">
                        <div dir="ltr">
                          <table cellspacing="0" cellpadding="0" border="0" style="background: none; border: 0px; margin: 0px; padding: 0px;">
                            <tbody>
                              <tr>
                                <td style="padding: 0px 0px 0px 12px;">
                                  <table cellspacing="0" cellpadding="0" border="0" style="background: none; border: 0px; margin: 0px; padding: 0px;">
                                    <tbody>
                                      <tr>
                                        <td colspan="2" style="padding-bottom: 5px; color: rgb(149, 183, 4); font-size: 18px;">{first} {last}</td>
                                      </tr>
                                      <tr>
                                        <td colspan="2" style="color: rgb(0, 0, 0); font-size: 14px;"><i>{RT}{title}{/RT}</i></td>
                                      </tr>
                                      <tr>
                                        <td colspan="2" style="color: rgb(0, 0, 0); font-size: 14px;"><strong>bigCompany s.r.o.</strong></td>
                                      </tr>
                                      <tr>
                                        <td width="20" valign="top" style="vertical-align: top; width: 20px; color: rgb(149, 183, 4); font-size: 14px;">p:</td>
                                        <td valign="top" style="vertical-align: top; color: rgb(0, 0, 0); font-size: 14px;">{RT}{phone}{/RT}</td>
                                      </tr>
                                      <tr>
                                        <td width="20" valign="top" style="vertical-align: top; width: 20px; color: rgb(149, 183, 4); font-size: 14px;">a:</td>
                                        <td valign="top" style="vertical-align: top; color: rgb(0, 0, 0); font-size: 14px;">Big Street 69, 333 03 NewYork</td>
                                      </tr>
                                      <tr>
                                        <td width="20" valign="top" style="vertical-align: top; width: 20px; color: rgb(149, 183, 4); font-size: 14px;">w:</td>
                                        <td valign="top" style="vertical-align: top; font-size: 14px;">
                                          https://www.example.test/

You’ve maybe noticed multiple variables/tags in the template. {first}, {last}, {last}, {title}, {phone}

These are going to be dynamically replaced by the value of your User. So if you are using your own signature template, you need to add these variables.

Adding {RT}{/RT} around the tag makes the variable skippable if user/users don’t have it, therefore not leaving an empty ugly space.

Note that for this to work USER HAVE TO HAVE THESE FILLED OUT. Otherwise, you’ll get the error phones.0.value” not found, organizations.0.title etc..

I suggest only using First and Last Name, if your company doesn’t by default fill Title and phone number.

More/less values

You can add some other variables which will be pulled from the user. To list all possible values

1
gam user <User Email Address> print allfields
1
gam ou <OU_name> print signature > signatures.csv

Don’t forget to change “" (without <> symbols)

Edit the file so only people without signature stays and pull necessary variable values from GW

1
gam csvkmd users signatures.csv keyfield User matchfield isPrimary True skipfield signature '.+' print fields name,organizations,ou,phones > Signatures_to_be_updated.csv

This is going to take the list of all users and their signatures, leaving only the ones without the signature variable filled out and print them in the wanted format with all the necessary variable values (name,organizations,ou,phones)

If you want to update the signatures of all the people (not only the ones without signatures)

1
gam csvkmd users signatures.csv keyfield User matchfield isPrimary True print fields name,organizations,ou,phones > Signatures_to_be_updated.csv

Update signatures of all the people without any signature

1
gam csv Signatures_to_be_updated.csv matchfield orgUnitPath "^/<OU_name>.*" gam user ~primaryEmail signature file signature_template html replace first ~name.givenName replace last ~name.familyName replace title ~organizations.0.title replace phone ~phones.0.value

Don’t forget to change “" (without <> symbols) If you have added more user variables, add those as well.

Run the script in the crontab

Create script

1
vim /root/scripts/update_signatures/update_signatures.sh
1
2
3
4
5
6
7
#!/bin/bash
/root/bin/gamadv-xtd3/gam ou <OU_name> print signature > /root/scripts/update_signatures/signatures.csv

/root/bin/gamadv-xtd3/gam csvkmd users signatures.csv keyfield User matchfield isPrimary True skipfield signature '.+' print fields name,organizations,ou,phones > /root/scripts/update_signatures/Signatures_to_be_updated.csv
#/root/bin/gamadv-xtd3/gam csvkmd users signatures.csv keyfield User matchfield isPrimary True print fields name,organizations,ou,phones > /root/scripts/update_signatures/Signatures_to_be_updated.csv

/root/bin/gamadv-xtd3/gam csv /root/scripts/update_signatures/Signatures_to_be_updated.csv matchfield orgUnitPath "^/<OU_name>.*" gam user ~primaryEmail signature file /root/scripts/update_signatures/signature_template html replace first ~name.givenName replace last ~name.familyName replace title ~organizations.0.title replace phone ~phones.0.value
1
chmod +x /root/scripts/update_signatures/update_signatures.sh

Create a cronjob

Run daily or change value according to your needs

1
0 8 * * * /root/scripts/update_signatures/update_signatures.sh 2>&1 >> /tmp/signatures_cron.log

Test cronjob

To see if your cronjob is working, you can force-run all your cronjobs with the following command

1
crontab -l | grep -v '^#' | cut -f 6- -d ' ' | while read CMD; do eval $CMD; done
This post is licensed under CC BY 4.0 by the author.