├── .gitignore ├── LICENSE ├── README.md └── scripts ├── complete_user_sync ├── README.md └── complete_user_sync.sh ├── group_add_remove ├── Group_Add_Remove_Script.sh └── README.md └── set-email-signature ├── README.md ├── setsig.py └── setsig.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *,cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ 58 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 daethnir 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | gam-tools 3 | ============ 4 | 5 | Tools that use the Google Apps Manager (GAM). 6 | 7 | What is it? 8 | =========== 9 | 10 | [GAM] is a free open source command line tool for Google Apps administrators 11 | to manage domain and user settings quickly and easily. 12 | 13 | GAM has some modes in which it can act in batch, by reading or exporting 14 | CSV data. However sometimes you need something more custom. 15 | 16 | This repository stores tools that use the gam code beyond the builtin 17 | functionality. Typically these are scripts (bash, powershell) that call 18 | gam based on other data sources. 19 | 20 | 21 | How secure is the code in here? 22 | =============================== 23 | 24 | Just because something is in here does not mean it has been 25 | tested or guaranteed to work. It's your responsibility to read 26 | the code and understand what it is doing. 27 | 28 | 29 | Adding scripts to the repository 30 | ================================ 31 | 32 | Want to add here? Great! Here are the ground rules. 33 | 34 | How do I get my changes into the repository? 35 | -------------------------------------------- 36 | 37 | This is a standard github repo, so the normal processes are what 38 | you need. 39 | 40 | * fork 41 | * make changes 42 | * issue a pull request 43 | 44 | The main repo owner will integrate pull requests as soon as possible 45 | and will only reject if they're clearly egregious, e.g. they have 46 | huge binaries, or are an obvious security nightmare. 47 | 48 | 49 | How should I organize contributions? 50 | ------------------------------------ 51 | 52 | Please create a directory with a README.md in the scripts directory 53 | that explains what it does and any restrictions (e.g. only works in 54 | GAM version X.Y and greater) for documentation. 55 | 56 | 57 | What should I commit? 58 | --------------------- 59 | 60 | Anything gam-utilizing code that you've written that could 61 | be useful for others, presumably bash / powershell / etc scripts. 62 | 63 | Binaries are not welcome at this time - source only. 64 | 65 | 66 | Can I commit someone else's code? 67 | --------------------------------- 68 | 69 | You can commit code that you get from others, for example that which 70 | is found on the [GAM Mailing List], if you've gotten their permission 71 | and they agree to the MIT license. 72 | 73 | 74 | [GAM]: https://github.com/jay0lee/GAM/ 75 | [GAM Mailing List]: http://groups.google.com/group/google-apps-manager 76 | 77 | -------------------------------------------------------------------------------- /scripts/complete_user_sync/README.md: -------------------------------------------------------------------------------- 1 | 2 | What this does 3 | ============== 4 | 5 | 6 | This is a Bash based Linux script that takes a list of Users from our Oracle Database (Banner 9) 7 | 8 | It then compares the file to a Current List of Google User and enables, disables, name changes, adds Users, change OU, updates passwords and adds user to Google Vault. 9 | 10 | It then sends me a log file of all the changes. I also has some built in checks, like if it is going to enable or disable over a 100 users at a time to stop and email me. 11 | 12 | Also if there are no updates, to not email me, and if there are any errors in the log file to send it to a larger group of people. 13 | -------------------------------------------------------------------------------- /scripts/complete_user_sync/complete_user_sync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LOGDIR='/opt/gam/LOGS' 4 | DIR='/opt/gam' 5 | CSVDIR='/opt/gam/CSV/Email' 6 | /bin/rm ${LOGDIR}/event.log ${LOGDIR}/eventswithvaultusers.log 7 | 8 | #---Get Users List from Google--- 9 | 10 | #Create a list of All Users (Active/Suspended) from Google ordered by Email, remove @test.domain.edu from email address and / from org for comparison 11 | 12 | /usr/bin/python ${DIR}/gam.py print users fullname ou suspended orderby email query 'orgUnitPath=/Student' > ${CSVDIR}/StudentAll.csv 13 | /usr/bin/python ${DIR}/gam.py print users fullname ou suspended orderby email query 'orgUnitPath=/Employee' > ${CSVDIR}/EmployeeAll.csv 14 | /usr/bin/python ${DIR}/gam.py print users fullname ou suspended orderby email query 'orgUnitPath=/Workstudy' > ${CSVDIR}/WorkstudyAll.csv 15 | /usr/bin/python ${DIR}/gam.py print users fullname ou suspended orderby email query 'orgUnitPath=/Emeritus' > ${CSVDIR}/EmeritusAll.csv 16 | 17 | #Append the files together, grep the user lines, sort alphabetical remove @test.domain.edu from email address and / from org, add CSV headers for comparison 18 | cat ${CSVDIR}/EmeritusAll.csv ${CSVDIR}/EmployeeAll.csv ${CSVDIR}/StudentAll.csv ${CSVDIR}/WorkstudyAll.csv | egrep 'Workstudy|Employee|Emeritus|Student' | sort | sed -e 's/@domain.edu//g' -e 's/\///g' -e '1s/^/Email,Lastname,FullName,Firstname,OU\n/' > ${CSVDIR}/GAMUSERLIST.csv 19 | 20 | #append the files together, grep the user lines, sort alphabetical remove @test.domain.edu from email address and / from org, add CSV headers for comparison 21 | cat ${CSVDIR}/EmeritusAll.csv ${CSVDIR}/EmployeeAll.csv ${CSVDIR}/StudentAll.csv ${CSVDIR}/WorkstudyAll.csv | grep ',False,' | sort | sed -e 's/@domain.edu//g' -e 's/\///g' -e '1s/^/Email,Lastname,Fullname,Firstname,OU,Suspended,SuspendedReason\n/' > ${CSVDIR}/GAMACTIVEUSERLIST.csv 22 | 23 | #Append the files together, grep the user lines, sort alphabetical remove @test.domain.edu from email address and / from org, add CSV headers for comparison 24 | cat ${CSVDIR}/EmeritusAll.csv ${CSVDIR}/StudentAll.csv ${CSVDIR}/EmployeeAll.csv ${CSVDIR}/WorkstudyAll.csv | grep ',True,' | sort | sed -e 's/@domain.edu//g' -e 's/\///g' -e '1s/^/Email,Lastname,Fullname,Firstname,OU,Suspended,SuspendedReason\n/' > ${CSVDIR}/GAMSUSPENDEDUSERLIST.csv 25 | 26 | #---Create, Suspend, and Enable Users--- 27 | 28 | #---Suspend Users--- 29 | 30 | #compare 1st column (username/email) from Banner Allusers and Google Users to create a suspend file, only print the first column (email/username) 31 | awk -F, 'FNR==NR {a[tolower($1)]++; next} !a[tolower($1)] {print $1}' ${CSVDIR}/AllUsers.csv ${CSVDIR}/GAMACTIVEUSERLIST.csv | sed '1s/^/Email\n/' > ${CSVDIR}/SuspendUsers.csv 32 | 33 | #Safety Check. If SuspendUsers has more than 100 lines,it will update passwords then cancel the Sync 34 | if [[ $(wc -l < ${CSVDIR}/SuspendUsers.csv) -ge 100 ]]; then 35 | /bin/rm ${LOGDIR}/Fail.log 36 | #update passwords even if the rest of the script is canceled 37 | /usr/bin/python ${DIR}/gam.py csv ${CSVDIR}/passwords.csv gam update user ~Email password ~Password >> ${LOGDIR}/Fail.log 2>&1 38 | echo "Cancelling Sync, Check Suspended User List, Certain Days will require the Safety Check be disabled. To disable the safety check: Edit the BannerToGoogleSync.sh file on Proxy1 located in /opt/gam and comment out the Safety Check section, re run the script, then uncomment the section" >> ${LOGDIR}/Fail.log 39 | /bin/cat ${LOGDIR}/Fail.log | mailx -s "Sync Failed to many Users to Suspend" blank@domain.edu 40 | exit 41 | fi; 42 | 43 | /bin/echo "Suspended Users" >> ${LOGDIR}/event.log 44 | /bin/echo "" >> ${LOGDIR}/event.log 45 | 46 | #upload/suspend users ~ references the CSV header from file 47 | /usr/bin/python ${DIR}/gam.py csv ${CSVDIR}/SuspendUsers.csv gam update user ~Email suspended on >> ${LOGDIR}/event.log 2>&1 48 | 49 | #---Re-Enable Users--- 50 | 51 | #compare 1st column from Banner Allusers to Google Suspended Users to create reenable file, only print first column (email/username) of accounts in both files (no need to added 'Email' header because it is one of the lines in common) 52 | awk -F, 'FNR==NR {a[tolower($1)]++; next} a[tolower($1)] {print $1,$4}' OFS="," ${CSVDIR}/GAMSUSPENDEDUSERLIST.csv ${CSVDIR}/AllUsers.csv > ${CSVDIR}/ReEnableUsers.csv 53 | 54 | #Safety Check. If ReEnableUsers has more than 100 lines, it will update passwords then cancel the sync 55 | if [[ $(wc -l < ${CSVDIR}/ReEnableUsers.csv) -ge 100 ]]; then 56 | /usr/bin/python ${DIR}/gam.py csv ${CSVDIR}/passwords.csv gam update user ~Email password ~Password >> ${LOGDIR}/fail.log 2>&1 57 | echo "Cancelling Sync, Check ReEnableUser List" >> ${LOGDIR}/Fail.log 58 | /bin/cat ${LOGDIR}/Fail.log | mailx -s "Sync Failed to many Users to Re-Enable" blank@domain.edu 59 | exit 60 | fi; 61 | 62 | /bin/echo "Re-Enabled Suspended Users" >> ${LOGDIR}/event.log 63 | /bin/echo "" >> ${LOGDIR}/event.log 64 | 65 | #upload/renable suspended users ~ reference the CSV Header from the File 66 | /usr/bin/python ${DIR}/gam.py csv ${CSVDIR}/ReEnableUsers.csv gam update user ~Email password ~Password suspended off >> ${LOGDIR}/event.log 2>&1 67 | 68 | #---Create New Users--- 69 | 70 | #compare 1st column (username/email) from Google ALLUserlist and BannerAllusers to create new user file with all columns 71 | awk -F, 'FNR==NR {a[tolower($1)]++; next} !a[tolower($1)]' ${CSVDIR}/GAMUSERLIST.csv ${CSVDIR}/AllUsers.csv | sed '1s/^/Email,Firstname,Lastname,Password,OU\n/' > ${CSVDIR}/NewUsers.csv 72 | 73 | /bin/echo "New Users" >> ${LOGDIR}/event.log 74 | /bin/echo "" >> ${LOGDIR}/event.log 75 | 76 | #upload/create the new users ~ references the CSV header from the file 77 | /usr/bin/python ${DIR}/gam.py csv ${CSVDIR}/NewUsers.csv gam create user ~Email firstname ~Firstname lastname ~Lastname password ~Password org ~OU >> ${LOGDIR}/event.log 2>&1 78 | 79 | #---Change Org--- 80 | 81 | #compare AllUsers to GAMUERSLIST on column 1 (username/email) and export 1st column (username) and 5th column (ORG) of matching username 82 | awk -F, 'FNR==NR {a[tolower($1)]++; next} a[tolower($1)] {print $1,$5}' OFS="," ${CSVDIR}/GAMUSERLIST.csv ${CSVDIR}/AllUsers.csv > ${CSVDIR}/matchingusersorg.csv 83 | 84 | #compare matchingusers file to GAMUSERLIST.csv on username and org, export differences, add CSV headers 85 | awk -F, 'FNR==NR {a[tolower($1 FS $5)]++; next} !a[tolower($1 FS $2)]' ${CSVDIR}/GAMUSERLIST.csv ${CSVDIR}/matchingusersorg.csv | sed '1s/^/Email,OU\n/' > ${CSVDIR}/ChangeOrg.csv 86 | 87 | #/bin/echo "" >> ${LOGDIR}/event.log 88 | /bin/echo "Users with Org Change" >> ${LOGDIR}/event.log 89 | /bin/echo "" >> ${LOGDIR}/event.log 90 | 91 | #run command to change org, ~ references CSV Header 92 | /usr/bin/python ${DIR}/gam.py csv ${CSVDIR}/ChangeOrg.csv gam update user ~Email org ~OU >> ${LOGDIR}/event.log 2>&1 93 | 94 | #---Make Changes to Active Users--- 95 | 96 | #---Change First/Last Name--- 97 | 98 | #compare AllUsers to GAMUERSLIST on column 1 (username/email) and export 1st (username), 2nd (first), 3rd (last) column of matching username 99 | awk -F, 'FNR==NR {a[tolower($1)]++; next} a[tolower($1)] {print $1,$2,$3}' OFS="," ${CSVDIR}/GAMUSERLIST.csv ${CSVDIR}/AllUsers.csv > ${CSVDIR}/matchingusersfirstlast.csv 100 | 101 | #compare matchingusers file to GAMUSERLIST.csv on username, first, and last. export differences, add CSV headers 102 | awk -F, 'FNR==NR {a[tolower($1 FS $4 FS $2)]++; next} !a[tolower($1 FS $2 FS $3)]' ${CSVDIR}/GAMUSERLIST.csv ${CSVDIR}/matchingusersfirstlast.csv | sed '1s/^/Email,Firstname,Lastname\n/' > ${CSVDIR}/ChangeFirstLast.csv 103 | 104 | #/bin/echo "" >> ${LOGDIR}/event.log 105 | /bin/echo "Users with First or Last Name Changes" >> ${LOGDIR}/event.log 106 | /bin/echo "" >> ${LOGDIR}/event.log 107 | 108 | #run command to change first/last name, ~ references CSV Header 109 | /usr/bin/python ${DIR}/gam.py csv ${CSVDIR}/ChangeFirstLast.csv gam update user ~Email firstname ~Firstname lastname ~Lastname >> ${LOGDIR}/event.log 2>&1 110 | 111 | #---Update User Passwords--- 112 | 113 | #/bin/echo "" >> ${LOGDIR}/event.log 114 | /bin/echo "Users with Password Update" >> ${LOGDIR}/event.log 115 | /bin/echo "" >> ${LOGDIR}/event.log 116 | 117 | #updating passwords that were changed in Banner in the last 3 hours and 5 minutes (3 hours instead of every 2, because the banner email creation script only runs every 3 hours, making the passwords pull overlap will prevent any possible password updates that did not yet have email accounts created, the 5 minutes prevents possible misses on how long it takes to run the scripts) 118 | /usr/bin/python ${DIR}/gam.py csv ${CSVDIR}/passwords.csv gam update user ~Email password ~Password >> ${LOGDIR}/event.log 2>&1 119 | 120 | #---Google VAULT--- 121 | 122 | #Pull down list of Vault Users, get just the username 123 | /usr/bin/python ${DIR}/gam.py print licenses | grep '@domain.edu' | sed -e 's/Google-Vault,//g' -e 's/,Google-Vault//g' -e 's/@domain.edu//g' | tr '[:upper:]' '[:lower:]' | sort > ${CSVDIR}/VaultUsers.csv 124 | 125 | #Pull down list of current active employees and generic accounts in Google, remove certain generic type accounts from the list (like room.xxx for calendars, and some training accounts) 126 | /usr/bin/python ${DIR}/gam.py print users orderby email query 'orgUnitPath=/Employee IsSuspended=False' | sed -e 's/@domain.edu//g' | grep "\." | sed -e 's/$/@domain.edu/g' > ${CSVDIR}/EmployeeActive.csv 127 | /usr/bin/python ${DIR}/gam.py print users orderby email query 'orgUnitPath=/Generic IsSuspended=False' | sed -e '/outlook.training/d' -e '/community/d' -e '/room./d' -e '/smartpendas/d' > ${CSVDIR}/GenericActive.csv 128 | 129 | #put the files together to make one active list with just username 130 | cat ${CSVDIR}/EmployeeActive.csv ${CSVDIR}/GenericActive.csv | grep '@domain.edu' | sed -e 's/@domain.edu//g' | tr '[:upper:]' '[:lower:]' | sort > ${CSVDIR}/EmployeeGenericActive.csv 131 | 132 | #compare EmployeeGenericActive.csv and VaultUsers.csv to see who needs to be added 133 | awk 'FNR==NR {a[$1]++; next} !a[$1]' ${CSVDIR}/VaultUsers.csv ${CSVDIR}/EmployeeGenericActive.csv > ${CSVDIR}/AddUsersToVault.csv 134 | 135 | /bin/echo "List of Users supposed to be added to Vault" >> ${LOGDIR}/event.log 136 | /bin/echo "" >> ${LOGDIR}/event.log 137 | 138 | #add the new users to Vault. Exporting to the Event Log for Errors only, Successful results do not create an output like Groups does. 139 | /usr/bin/python ${DIR}/gam.py file ${CSVDIR}/AddUsersToVault.csv add license Vault Google-Vault >> ${LOGDIR}/event.log 2>&1 140 | 141 | #Vault GAM Code does not output added Users info, Adding the New Vault Users File to show new users instead 142 | /bin/cat ${LOGDIR}/event.log ${CSVDIR}/AddUsersToVault.csv > ${LOGDIR}/eventswithvaultusers.log 143 | 144 | #We currently do not remove Users from Vault, this policy may change, if you remove a license we will lose any deleted emails 145 | 146 | #Email 147 | 148 | #if no accounts are updated do not send email (if an account was updated a @ symbol would be in the log file) 149 | AT_SYMBOL_EXIST=$(cat ${LOGDIR}/eventswithvaultusers.log | grep @) 150 | if [ $? -eq 1 ] 151 | then 152 | exit 153 | fi 154 | 155 | #if there is an error in the log send to blank@domain.edu (if an error exist the word 'error' will be in the log file) 156 | ERROR_EXIST=$(cat ${LOGDIR}/eventswithvaultusers.log | grep -i error) 157 | if [ $? -eq 0 ] 158 | then 159 | /bin/cat ${LOGDIR}/eventswithvaultusers.log | sed -e 's/starting 5 worker threads...//g' -e 's/updating user//g' -e 's/Creating account for //g' -e 's/^[ \t]*//' | mailx -s "Error in Google Sync" blank@domain.edu 160 | exit 161 | fi 162 | 163 | #if at least one account was update and no Errors were encountered send email to just Andrew 164 | /bin/cat ${LOGDIR}/eventswithvaultusers.log | sed -e 's/starting 5 worker threads...//g' -e 's/updating user//g' -e 's/adding member//g' -e 's/Creating account for //g' -e 's/added.* to group//g' -e 's/^[ \t]*//' | mailx -s "User Update/Creation Results" blank1+google@domain.edu 165 | 166 | #Remove Files after sync that include password in plain text 167 | rm -rf ${CSVDIR}/ReEnableUsers.csv ${CSVDIR}/NewUsers.csv ${CSVDIR}/passwords.csv ${CSVDIR}/AllUsers.csv 168 | 169 | -------------------------------------------------------------------------------- /scripts/group_add_remove/Group_Add_Remove_Script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR='/opt/gam/gam-test' 3 | 4 | #Create All Employee Group list 5 | /usr/bin/python ${DIR}/gam.py info group employees.all | grep '(user)' | sed -e 's/member://g' -e 's/manager://g' -e 's/owner://g' -e 's/(user)//g' -e 's/@test.aims.edu//g' -e 's/^[ \t]*//' -e 's/ *$//' | tr '[:upper:]' '[:lower:]' | /bin/sort > ${DIR}/EmployeesAllGroup.csv 6 | 7 | #Compare Active Google Employee List to Current Employee Group list from Banner to see who needs to be removed 8 | awk 'FNR==NR {a[$1]++; next} !a[$1]' ${DIR}/allemployeegroupclean.csv ${DIR}/EmployeesAllGroup.csv > ${DIR}/RemoveUsersFromAllEmployeeGroup.csv 9 | 10 | #Compare Employee Group from Banner to Google Active Employee List to see who needs to be added 11 | awk 'FNR==NR {a[$1]++; next} !a[$1]' ${DIR}/EmployeesAllGroup.csv ${DIR}/allemployeegroupclean.csv > ${DIR}/AddUsersToAllEmployeeGroup.csv 12 | 13 | 14 | #Add Users 15 | /usr/bin/python ${DIR}/gam.py update group employees.all add file ${DIR}/AddUsersToAllEmployeeGroup.csv >> ${DIR}/event.log 2>&1 16 | 17 | #Remove Users 18 | /usr/bin/python ${DIR}/gam.py update group employees.all remove file ${DIR}/RemoveUsersFromAllEmployeeGroup.csv >> ${DIR}/event.log 2>&1 19 | -------------------------------------------------------------------------------- /scripts/group_add_remove/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | What this does 4 | ============== 5 | 6 | This is a Bash based script that I use to 7 | compare a list of Users I pull from Banner (Oracle 8 | Database) to a list I pull from an exist Google Group. I 9 | then add or remove based on the comparison. 10 | -------------------------------------------------------------------------------- /scripts/set-email-signature/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | setsig 4 | ============ 5 | 6 | This tool has two components. 7 | 8 | WARNING 9 | ======= 10 | 11 | 12 | These scripts are sanitized versions of our real ones. 13 | As such, you will be expected to fix as needed, 14 | They have had minimal testing. 15 | 16 | 17 | setsig.py 18 | ========= 19 | 20 | This script takes command line options and generates a 'dynamic' 21 | signature (based on username/first/last) and sets the signature 22 | for the user. 23 | 24 | You should change the actual signature content block to what you 25 | like (perhaps adding your personal flair/branding), as well as 26 | the globals at the top that define domains and such. 27 | 28 | Should run anywhere python works. 29 | 30 | setsig.sh 31 | ========= 32 | 33 | Reads a list of usernames and, if the user does not have 34 | a signature already defined, calls setsig.py to set it. 35 | 36 | Pulls the first/last name info (inelegantly) from the gecos 37 | field. 38 | 39 | Should run on POSIX (e.g. Linux) systems where user info is 40 | available via getent. 41 | -------------------------------------------------------------------------------- /scripts/set-email-signature/setsig.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """Set user's gmail signature.""" 3 | 4 | import optparse 5 | import subprocess 6 | import textwrap 7 | 8 | 9 | DOMAIN = 'example.com' 10 | WEBSITE = 'www.example.com' 11 | IMAGE = 'http://www.example.com/sig.png' 12 | 13 | 14 | def main(): 15 | """Set user's Gmail Sig.""" 16 | 17 | parser = optparse.OptionParser() 18 | parser.add_option('--username', '-u', dest='username', 19 | help="username") 20 | parser.add_option('--firstname', '-f', dest='firstname', 21 | help="firstname") 22 | parser.add_option('--lastname', '-l', dest='lastname', 23 | help="lastname") 24 | 25 | opts, args = parser.parse_args() 26 | 27 | if not (opts.username and opts.firstname and opts.lastname): 28 | parser.error('username, firstname, and lastname all required.') 29 | if args: 30 | parser.error('Extraneous command line options found.') 31 | 32 | content = textwrap.dedent("""\ 33 |