├── OOO ├── README.md ├── g4oCheck ├── init ├── nGroup.computer ├── nGroup.comsoc ├── nGroup.ieee ├── nGroup.mga ├── nUser.computer ├── nUser.comsoc ├── nUser.ieee ├── nUser.it ├── onLeave ├── purgeFrom ├── termUser ├── termUser.extended └── termUser.never /OOO: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/userterm.csv 3 | OLDIFS=$IFS 4 | IFS=, 5 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 6 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 7 | while read userEmail userFirst userLast managerEmail managerPhone 8 | do 9 | domain=${userEmail/*@/ } 10 | userId=${userEmail/@*/ } 11 | userId="$(echo -e "${userId}" | sed -e 's/[[:space:]]*$//')" 12 | domain="$(echo -e "${domain}" | sed -e 's/^[[:space:]]*//')" 13 | domain="@$domain" 14 | dateStamp=_onleave_$(date +%Y%m%d) 15 | newEmail=$userId$dateStamp$domain 16 | if [ -z "$1" ] 17 | then 18 | echo -e "\e[91m\e[7mALERT:\e[0m To be used only for Out of Office procedure" 19 | echo -e "to process changes use \e[91m./OOO doit\e[0m" 20 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 21 | echo -e "\e[1mOut of Office User: \e[0m$userEmail" 22 | echo -e "\e[1mDelegate to: \e[0m$managerEmail ($managerPhone)" 23 | echo -e "\e[1mVacation Responder: \e[0m" 24 | echo -e " $userFirst $userLast is on leave, please contact $userFirst's manager at" 25 | echo -e " <$managerEmail> or by telephone at $managerPhone. \n\n Thank You. \n IEEE Support." 26 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 27 | echo 28 | else 29 | if [ "${1^^}" == "DOIT" ] 30 | then 31 | echo -e "---[ \e[93m\e[1mOut of Office Process for User \e[36m$userFirst $userLast \e[0m]---\e[32m" 32 | echo "* $timestamp * $userEmail - Out of Office Process Start" >> ~/gam-data/gam-data.log 33 | echo -e "\e[36m- Set Vacation Message\e[0m" 34 | ~/bin/gam/gam user $userEmail vacation on subject "$userFirst $userLast is on leave:" message "$userFirst $userLast is on leave, please contact $userFirst's manager by email at <$managerEmail> or by telephone at $managerPhone. \n\n Thank You, \n IEEE Support." startdate $(date +%Y-%m-%d) enddate 2099-12-30 35 | echo "* $timestamp * $newEmail - Set vacation responder to $managerEmail ($managerPhone)" >> ~/gam-data/gam-data.log 36 | echo "* $timestamp * $userEmail - Out of Office Process Complete" >> ~/gam-data/gam-data.log 37 | echo -e "\e[0m---[ \e[93m\e[1m Out of Office Process Complete for \e[36m$userFirst $userLast \e[0m]---" 38 | echo 39 | fi 40 | fi 41 | done < $INPUT 42 | IFS=$OLDIFS 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a set of GAM scripts that we use for our environment over at the IEEE. 2 | Once Google Apps Manager is set up and running, these scripts handle some basic 3 | automation we have based on IEEE needs. 4 | 5 | nGroup.* - creates group(s) from an input file 6 | assigns manager to the group 7 | sets a few group specific settings 8 | 9 | nUser.* - provisions a user from an input file 10 | puts the user in the proper ORG 11 | assigns the user to a group based on department 12 | assigns a Vault license to that user 13 | 14 | termUser.* - process a user for termination from an input file 15 | renames the user based on the date and time of the script run 16 | puts the user in a terminated ORG (for Vault Retention purposes) 17 | adds delegation to the manager 18 | sets the vacation message of the user 19 | revokes all keys, mobile devices, and oauth codes 20 | randomizes the password 21 | 22 | To download and use these scripts, or just to view them for reference: 23 | 24 | - Install Google Apps Manager: https://github.com/jay0lee/GAM/wiki 25 | - Once GAM is successfully installed and working, use the following 26 | command to clone the script repository 27 | 28 | git clone https://github.com/KevinMelilloIEEE/gam-script 29 | 30 | - change to the gam-script directory, usually ~/gam-script 31 | - run ./init to create the initial data directories, modify your 32 | ~/.bashrc file, and then restart your shell 33 | 34 | To update your local version with changes that are in the MASTER REPOSITORY 35 | 36 | git pull --rebase origin master 37 | -------------------------------------------------------------------------------- /g4oCheck: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -z "$1" ] 3 | then 4 | echo -e "\e[91m\e[7mALERT:\e[0m Need to provide G4O Section Number" 5 | echo -e "to check use \e[91m./g4oCheck r123456\e[0m" 6 | echo 7 | else 8 | g4oPrefix="g4o_" 9 | g4oServiceSuffix="_svc@ieee.org" 10 | g4oMemberSuffix="_mem@ieee.org" 11 | g4oVolunteerSuffix="_vol@ieee.org" 12 | g4oServiceAccount=$g4oPrefix$1$g4oServiceSuffix 13 | g4oMemberGroup=$g4oPrefix$1$g4oMemberSuffix 14 | g4oVolunteerGroup=$g4oPrefix$1$g4oVolunteerSuffix 15 | echo -e "---[ \e[93m\e[1mChecking g4o for \e[36m$g4oServiceAccount \e[0m]---\e[32m" 16 | echo -e " [ \e[93m\e[1mUser Information \e[0m]---\e[32m" 17 | ~/bin/gam/gam info user $g4oServiceAccount 18 | echo 19 | echo -e " [ \e[93m\e[1mUser Member Group \e[0m]---\e[32m" 20 | ~/bin/gam/gam info group $g4oMemberGroup 21 | echo -e " [ \e[93m\e[1mUser Volunteer Group \e[0m]---\e[32m" 22 | ~/bin/gam/gam info group $g4oVolunteerGroup 23 | echo -e " [ \e[93m\e[1mDrive File ID Check\e[0m]---\e[32m" 24 | ~/bin/gam/gam user $g4oServiceAccount show filelist id 25 | ~/bin/gam/gam user $g4oServiceAccount show filelist id >> ~/gam-data/tmp.g4o-permissions.csv 26 | echo -e " [ \e[93m\e[1mDrive File Permissions\e[0m]---\e[32m" 27 | ~/bin/gam/gam csv ~/gam-data/tmp.g4o-permissions.csv gam user ~Owner show drivefileacl ~id 28 | echo -e "\e[0m---[ \e[93m\e[1m Check Complete for \e[36m$g4oServiceAccount \e[0m]---" 29 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 30 | echo "* $timestamp * g4o Check completed on $g4oServiceAccount." >> ~/gam-data/gam-data.log 31 | 32 | fi 33 | -------------------------------------------------------------------------------- /init: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | 3 | echo -e "# *** Begin additions from INIT ***" >> ~/.bashrc 4 | 5 | # Set up data files, and default information inside those files 6 | mkdir ~/gam-data 7 | touch ~/gam-data/grouplist.csv 8 | echo -e "manager_email,groupname_prefix,group_info_prefix" >> ~/gam-data/grouplist.csv 9 | touch ~/gam-data/userlist.csv 10 | echo -e "email_prefix,First_name,Last_name,OU,group_prefix" >> ~/gam-data/userlist.csv 11 | touch ~/gam-data/userterm.csv 12 | echo -e "email_address@domain.com,First_Name,Last_Name,manager_email@domain.com,123.456.7890" >> ~/gam-data/userterm.csv 13 | touch ~/gam-data/gam-data.log 14 | 15 | # Set up .bashrc for the following commands: 16 | 17 | # grouplist - edit the group list file to create groups 18 | echo -e " " >> ~/.bashrc 19 | echo -e "# type 'grouplist' to edit the group list file for additons" >> ~/.bashrc 20 | echo -e "grouplist () {" >> ~/.bashrc 21 | echo -e " cd ~/gam-script" >> ~/.bashrc 22 | echo -e " nano ~/gam-data/grouplist.csv" >> ~/.bashrc 23 | echo -e "}" >> ~/.bashrc 24 | echo -e " " >> ~/.bashrc 25 | 26 | # newuser - edit the new user file to on-board users 27 | echo -e " " >> ~/.bashrc 28 | echo -e "# type 'newuser' to edit the new user list for on-boarding" >> ~/.bashrc 29 | echo -e "newuser () {" >> ~/.bashrc 30 | echo -e " cd ~/gam-script" >> ~/.bashrc 31 | echo -e " nano ~/gam-data/userlist.csv" >> ~/.bashrc 32 | echo -e "}" >> ~/.bashrc 33 | echo -e " " >> ~/.bashrc 34 | 35 | # termuser - edit the term user file to off-board users 36 | echo -e " " >> ~/.bashrc 37 | echo -e "# type 'termuser' to edit the term user list for off-boarding" >> ~/.bashrc 38 | echo -e "termuser () {" >> ~/.bashrc 39 | echo -e " cd ~/gam-script" >> ~/.bashrc 40 | echo -e " nano ~/gam-data/userterm.csv" >> ~/.bashrc 41 | echo -e "}" >> ~/.bashrc 42 | echo -e " " >> ~/.bashrc 43 | 44 | 45 | 46 | 47 | echo -e "# *** END additions from INIT ***" >> ~/.bashrc 48 | echo -e "\e[91m\e[7mALERT:\e[0m You must restart your shell for the commands to be active." 49 | echo -e "\e[91m\e[7mALERT:\e[0m Please review your ~/.bashrc file for the changes." 50 | -------------------------------------------------------------------------------- /nGroup.computer: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/grouplist.csv 3 | OLDIFS=$IFS 4 | IFS=, 5 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 6 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 7 | while read groupManager groupName groupDesc 8 | do 9 | groupSuffix="@computer.org" 10 | aliasSuffix="@gapps.ieee.org" 11 | tGroupName=$groupName$groupSuffix 12 | tAlias=$groupName$aliasSuffix 13 | if [ -z "$1" ] 14 | then 15 | echo -e "to process changes use \e[91mnGroup.ieee doit\e[0m" 16 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 17 | echo -e "\e[1mGroup Name: \e[0m$tGroupName" 18 | echo -e "\e[1mAlias: \e[0m$tAlias" 19 | echo -e "\e[1mManager: \e[0m$groupManager" 20 | echo -e "\e[36mSetting spam_moderation_level to allow\e[0m" 21 | echo -e "\e[36mSetting who_can_leave_group to ALL_MANAGERS_CAN_LEAVE\e[0m" 22 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 23 | echo 24 | else 25 | if [ "${1^^}" == "DOIT" ] 26 | then 27 | echo -e "---[ \e[93m\e[1mCreating Group \e[36m$tGroupName \e[0m]---\e[32m" 28 | ~/bin/gam/gam create group $tGroupName name $groupName description $groupDesc 29 | ~/bin/gam/gam create alias $tAlias group $tGroupName 30 | ~/bin/gam/gam update group $tGroupName add manager user $groupManager 31 | ~/bin/gam/gam update group $tGroupName spam_moderation_level allow 32 | ~/bin/gam/gam update group $tGroupName who_can_leave_group ALL_MANAGERS_CAN_LEAVE 33 | echo "* $timestamp * $tGroupname - created ($groupManager)" >> ~/gam-data/gam-data.log 34 | echo -e "\e[0m---[ \e[93m\e[1m Creation Complete for \e[36m$tGroupName \e[0m]---" 35 | echo 36 | echo "Please respond to the request with the following:" 37 | echo 38 | echo "Google Group $groupName has been created and you have been assigned" 39 | echo "as the manager with full access to add and remove members. You can" 40 | echo "access your new group by clicking on the grid (top right) and choosing" 41 | echo "'Groups'. Click 'My Groups' and choose the group name from the list" 42 | echo "of groups. Click on 'Manage' (upper right) to manage the member list." 43 | echo "Choose 'Direct add members' (Left under Members) to add a subscriber." 44 | echo "Enter the email address, then click add." 45 | echo 46 | echo "Also add the alias to cs-listserv" 47 | echo "/usr/local/Mail/src/common-aliases" 48 | echo 49 | fi 50 | fi 51 | 52 | done < $INPUT 53 | IFS=$OLDIFS 54 | -------------------------------------------------------------------------------- /nGroup.comsoc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/grouplist.csv 3 | OLDIFS=$IFS 4 | IFS=, 5 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 6 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 7 | while read groupManager groupName groupDesc 8 | do 9 | groupSuffix="@comsoc.org" 10 | aliasSuffix="@gapps.ieee.org" 11 | tGroupName=$groupName$groupSuffix 12 | tAlias=$groupName$aliasSuffix 13 | if [ -z "$1" ] 14 | then 15 | echo -e "to process changes use \e[91mnGroup.comsoc doit\e[0m" 16 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 17 | echo -e "\e[1mGroup Name: \e[0m$tGroupName" 18 | echo -e "\e[1mAlias: \e[0m$tAlias" 19 | echo -e "\e[1mManager: \e[0m$groupManager" 20 | echo -e "\e[36mSetting spam_moderation_level to allow\e[0m" 21 | echo -e "\e[36mSetting who_can_leave_group to ALL_MANAGERS_CAN_LEAVE\e[0m" 22 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 23 | echo 24 | else 25 | if [ "${1^^}" == "DOIT" ] 26 | then 27 | echo -e "---[ \e[93m\e[1mCreating Group \e[36m$tGroupName \e[0m]---\e[32m" 28 | ~//bin/gam/gam create group $tGroupName name $groupName description $groupDesc 29 | ~/bin/gam/gam create alias $tAlias group $tGroupName 30 | ~/bin/gam/gam update group $tGroupName add manager user $groupManager 31 | ~/bin/gam/gam update group $tGroupName spam_moderation_level allow 32 | ~/bin/gam/gam update group $tGroupName who_can_leave_group ALL_MANAGERS_CAN_LEAVE 33 | echo "* $timestamp * $tGroupName - created ($groupManager)" >> ~/gam-data/gam-data.log 34 | echo -e "\e[0m---[ \e[93m\e[1m Creation Complete for \e[36m$tGroupName \e[0m]---" 35 | echo 36 | echo "Please respond to the request with the following:" 37 | echo 38 | echo "Google Group $groupName has been created and you have been assigned" 39 | echo "as the manager with full access to add and remove members. You can" 40 | echo "access your new group by clicking on the grid (top right) and choosing" 41 | echo "'Groups'. Click 'My Groups' and choose the group name from the list" 42 | echo "of groups. Click on 'Manage' (upper right) to manage the member list." 43 | echo "Choose 'Direct add members' (Left under Members) to add a subscriber." 44 | echo "Enter the email address, then click add." 45 | echo 46 | fi 47 | fi 48 | 49 | done < $INPUT 50 | IFS=$OLDIFS 51 | -------------------------------------------------------------------------------- /nGroup.ieee: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/grouplist.csv 3 | OLDIFS=$IFS 4 | IFS=, 5 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 6 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 7 | while read groupManager groupName groupDesc 8 | do 9 | groupSuffix="@ieee.org" 10 | aliasSuffix="@gapps.ieee.org" 11 | tGroupName=$groupName$groupSuffix 12 | tAlias=$groupName$aliasSuffix 13 | if [ -z "$1" ] 14 | then 15 | echo -e "to process changes use \e[91mnGroup.ieee doit\e[0m" 16 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 17 | echo -e "\e[1mGroup Name: \e[0m$tGroupName" 18 | echo -e "\e[1mAlias: \e[0m$tAlias" 19 | echo -e "\e[1mManager: \e[0m$groupManager" 20 | echo -e "\e[36mSetting spam_moderation_level to allow\e[0m" 21 | echo -e "\e[36mSetting who_can_leave_group to ALL_MANAGERS_CAN_LEAVE\e[0m" 22 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 23 | echo 24 | else 25 | if [ "${1^^}" == "DOIT" ] 26 | then 27 | echo -e "---[ \e[93m\e[1mCreating Group \e[36m$tGroupName \e[0m]---\e[32m" 28 | ~/bin/gam/gam create group $tGroupName name $groupName description $groupDesc 29 | ~/bin/gam/gam create alias $tAlias group $tGroupName 30 | ~/bin/gam/gam update group $tGroupName add manager user $groupManager 31 | ~/bin/gam/gam update group $tGroupName spam_moderation_level allow 32 | ~/bin/gam/gam update group $tGroupName who_can_leave_group ALL_MANAGERS_CAN_LEAVE 33 | echo "* $timestamp * $tGroupName - created ($groupManager)" >> ~/gam-data/gam-data.log 34 | echo -e "\e[0m---[ \e[93m\e[1m Creation Complete for \e[36m$tGroupName \e[0m]---" 35 | echo 36 | echo "Please respond to the request with the following:" 37 | echo 38 | echo "Google Group $groupName has been created and you have been assigned" 39 | echo "as the manager with full access to add and remove members. You can" 40 | echo "access your new group by clicking on the grid (top right) and choosing" 41 | echo "'Groups'. Click 'My Groups' and choose the group name from the list" 42 | echo "of groups. Click on 'Manage' (upper right) to manage the member list." 43 | echo "Choose 'Direct add members' (Left under Members) to add a subscriber." 44 | echo "Enter the email address, then click add." 45 | echo 46 | fi 47 | fi 48 | 49 | done < $INPUT 50 | IFS=$OLDIFS 51 | -------------------------------------------------------------------------------- /nGroup.mga: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/grouplist.csv 3 | OLDIFS=$IFS 4 | IFS=, 5 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 6 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 7 | while read groupManager groupName groupDesc 8 | do 9 | groupSuffix="@ieee.org" 10 | aliasSuffix="@gapps.ieee.org" 11 | tGroupName=$groupName$groupSuffix 12 | tAlias=$groupName$aliasSuffix 13 | if [ -z "$1" ] 14 | then 15 | echo -e "to process changes use \e[91mnGroup.ieee doit\e[0m" 16 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 17 | echo -e "\e[1mGroup Name: \e[0m$tGroupName" 18 | echo -e "\e[1mAlias: \e[0m$tAlias" 19 | echo -e "\e[1mManager: \e[0m$groupManager" 20 | echo -e "\e[36mSetting spam_moderation_level to allow\e[0m" 21 | echo -e "\e[36mSetting who_can_leave_group to ALL_MANAGERS_CAN_LEAVE\e[0m" 22 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 23 | echo 24 | else 25 | if [ "${1^^}" == "DOIT" ] 26 | then 27 | echo -e "---[ \e[93m\e[1mCreating Group \e[36m$tGroupName \e[0m]---\e[32m" 28 | ~//bin/gam/gam create group $tGroupName name $groupName description $groupDesc 29 | ~/bin/gam/gam create alias $tAlias group $tGroupName 30 | ~/bin/gam/gam update group $tGroupName add manager nomail user v.sharoff@ieee.org 31 | ~/bin/gam/gam update group $tGroupName add manager nomail user h.shiminsky@ieee.org 32 | ~/bin/gam/gam update group $tGroupName add manager nomail user k.n.luu@ieee.org 33 | ~/bin/gam/gam update group $tGroupName spam_moderation_level allow allow_external_members true 34 | ~/bin/gam/gam update group $tGroupName who_can_leave_group ALL_MANAGERS_CAN_LEAVE 35 | echo "* $timestamp * $tGroupName - created ($groupManager)" >> ~/gam-data/gam-data.log 36 | echo -e "\e[0m---[ \e[93m\e[1m Creation Complete for \e[36m$tGroupName \e[0m]---" 37 | echo 38 | echo "Please respond to the request with the following:" 39 | echo 40 | echo "Google Group $groupName has been created and you have been assigned" 41 | echo "as the manager with full access to add and remove members. You can" 42 | echo "access your new group by clicking on the grid (top right) and choosing" 43 | echo "'Groups'. Click 'My Groups' and choose the group name from the list" 44 | echo "of groups. Click on 'Manage' (upper right) to manage the member list." 45 | echo "Choose 'Direct add members' (Left under Members) to add a subscriber." 46 | echo "Enter the email address, then click add." 47 | echo 48 | fi 49 | fi 50 | 51 | done < $INPUT 52 | IFS=$OLDIFS 53 | -------------------------------------------------------------------------------- /nUser.computer: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/userlist.csv 3 | OLDIFS=$IFS 4 | IFS=, 5 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 6 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 7 | while read userName firstName lastName orgName groupName 8 | do 9 | orgPrefix="/STAFF" 10 | emailSuffix="@computer.org" 11 | groupSuffix="_staff@computer.org" 12 | aliasSuffix="@gapps.ieee.org" 13 | tUser="$userName$emailSuffix" 14 | tOrg="/STAFF/$orgName" 15 | tGroup="$groupName$groupSuffix" 16 | tAlias="$userName$aliasSuffix" 17 | if [ -z "$1" ] 18 | then 19 | echo -e "\e[91m\e[7mALERT:\e[0m To be used only for Computer.org Staff" 20 | echo -e "to process changes use \e[91m./nUser.computer doit\e[0m" 21 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 22 | echo -e "\e[1mCreate User: \e[0m$tUser" 23 | echo -e "\e[1mAdd Alias: \e[0m$tAlias" 24 | echo -e "\e[1mOrganization: \e[0m$tOrg" 25 | echo -e "\e[1mGroup: \e[0m$tGroup" 26 | echo -e "\e[36mAdd Vault License\e[0m" 27 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 28 | echo 29 | else 30 | if [ "${1^^}" == "DOIT" ] 31 | then 32 | echo -e "---[ \e[93m\e[1mCreating User \e[36m$tUser \e[0m]---\e[32m" 33 | ~/bin/gam/gam create user $tUser firstname $firstName lastname $lastName org $tOrg 34 | echo "* $timestamp * $tUser - created ($tOrg)" >> ~/gam-data/gam-data.log 35 | ~/bin/gam/gam create alias $tAlias user $tUser 36 | echo "* $timestamp * $tUser - added alias of $tAlias" >> ~/gam-data/gam-data.log 37 | ~/bin/gam/gam update group $tGroup add member $tUser 38 | echo "* $timestamp * $tUser - added to group $tGroup" >> ~/gam-data/gam-data.log 39 | echo -e "\e[0m---[ \e[93m\e[1m Creation Complete for \e[36m$tUser \e[0m]---" 40 | fi 41 | fi 42 | done < $INPUT 43 | IFS=$OLDIFS 44 | -------------------------------------------------------------------------------- /nUser.comsoc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/userlist.csv 3 | OLDIFS=$IFS 4 | IFS=, 5 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 6 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 7 | while read userName firstName lastName orgName groupName 8 | do 9 | orgPrefix="/STAFF" 10 | emailSuffix="@comsoc.org" 11 | groupSuffix="_staff@comsoc.org" 12 | aliasSuffix="@gapps.ieee.org" 13 | tUser="$userName$emailSuffix" 14 | tOrg="/STAFF/$orgName" 15 | tGroup="$groupName$groupSuffix" 16 | tAlias="$userName$aliasSuffix" 17 | if [ -z "$1" ] 18 | then 19 | echo -e "\e[91m\e[7mALERT:\e[0m To be used only for COMSOC Staff" 20 | echo -e "to process changes use \e[91m./nUser.comsoc doit\e[0m" 21 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 22 | echo -e "\e[1mCreate User: \e[0m$tUser" 23 | echo -e "\e[1mAdd Alias: \e[0m$tAlias" 24 | echo -e "\e[1mOrganization: \e[0m$tOrg" 25 | echo -e "\e[1mGroup: \e[0m$tGroup" 26 | echo -e "\e[36mAdd Vault License\e[0m" 27 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 28 | echo 29 | else 30 | if [ "${1^^}" == "DOIT" ] 31 | then 32 | echo -e "---[ \e[93m\e[1mCreating User \e[36m$tUser \e[0m]---\e[32m" 33 | ~/bin/gam/gam create user $tUser firstname $firstName lastname $lastName org $tOrg 34 | echo "* $timestamp * $tUser - created ($tOrg)" >> ~/gam-data/gam-data.log 35 | ~/bin/gam/gam create alias $tAlias user $tUser 36 | echo "* $timestamp * $tUser - added alias of $tAlias" >> ~/gam-data/gam-data.log 37 | ~/bin/gam/gam update group $tGroup add member $tUser 38 | echo "* $timestamp * $tUser - added to group $tGroup" >> ~/gam-data/gam-data.log 39 | echo -e "\e[0m---[ \e[93m\e[1m Creation Complete for \e[36m$tUser \e[0m]---" 40 | fi 41 | fi 42 | done < $INPUT 43 | IFS=$OLDIFS 44 | -------------------------------------------------------------------------------- /nUser.ieee: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/userlist.csv 3 | OLDIFS=$IFS 4 | IFS=, 5 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 6 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 7 | while read userName firstName lastName orgName groupName 8 | do 9 | orgPrefix="/STAFF" 10 | emailSuffix="@ieee.org" 11 | groupSuffix="_staff@ieee.org" 12 | aliasSuffix="@gapps.ieee.org" 13 | tUser="$userName$emailSuffix" 14 | tOrg="/STAFF/$orgName" 15 | secondAlias="$(echo "$userName" | sed 's/\./-/g')" 16 | sAlias="$secondAlias$emailSuffix" 17 | tGroup="$groupName$groupSuffix" 18 | tAlias="$userName$aliasSuffix" 19 | if [ -z "$1" ] 20 | then 21 | echo -e "\e[91m\e[7mALERT:\e[0m To be used only for Computer.org Staff" 22 | echo -e "to process changes use \e[91m./nUser.computer doit\e[0m" 23 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 24 | echo -e "\e[1mCreate User: \e[0m$tUser" 25 | echo -e "\e[1mAdd Alias: \e[0m$tAlias" 26 | echo -e "\e[1mSecond Alias: \e[0m$sAlias" 27 | echo -e "\e[1mOrganization: \e[0m$tOrg" 28 | echo -e "\e[1mGroup: \e[0m$tGroup" 29 | echo -e "\e[36mAdd Vault License\e[0m" 30 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 31 | echo 32 | else 33 | if [ "${1^^}" == "DOIT" ] 34 | then 35 | echo -e "---[ \e[93m\e[1mCreating User \e[36m$tUser \e[0m]---\e[32m" 36 | ~/bin/gam/gam create user $tUser firstname $firstName lastname $lastName org $tOrg 37 | echo "* $timestamp * $tUser - created ($tOrg)" >> ~/gam-data/gam-data.log 38 | ~/bin/gam/gam create alias $tAlias user $tUser 39 | ~/bin/gam/gam create alias $sAlias user $tUser 40 | echo "* $timestamp * $tUser - added alias of $tAlias" >> ~/gam-data/gam-data.log 41 | ~/bin/gam/gam update group $tGroup add member $tUser 42 | echo "* $timestamp * $tUser - added to group $tGroup" >> ~/gam-data/gam-data.log 43 | echo -e "\e[0m---[ \e[93m\e[1m Creation Complete for \e[36m$tUser \e[0m]---" 44 | fi 45 | fi 46 | done < $INPUT 47 | IFS=$OLDIFS 48 | -------------------------------------------------------------------------------- /nUser.it: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/userlist.csv 3 | OLDIFS=$IFS 4 | IFS=, 5 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 6 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 7 | while read userName firstName lastName orgName groupName 8 | do 9 | orgPrefix="/STAFF" 10 | emailSuffix="@ieee.org" 11 | groupSuffix="staff@ieee.org" 12 | aliasSuffix="@gapps.ieee.org" 13 | tUser="$userName$emailSuffix" 14 | tOrg="/STAFF/$orgName" 15 | tGroup="$groupName$groupSuffix" 16 | tAlias="$userName$aliasSuffix" 17 | if [ -z "$1" ] 18 | then 19 | echo -e "\e[91m\e[7mALERT:\e[0m To be used only for IEEE Staff" 20 | echo -e "to process changes use \e[91m./nUser.ieee doit\e[0m" 21 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 22 | echo -e "\e[1mCreate User: \e[0m$tUser" 23 | echo -e "\e[1mAdd Alias: \e[0m$tAlias" 24 | echo -e "\e[1mOrganization: \e[0m$tOrg" 25 | echo -e "\e[1mGroup: \e[0m$tGroup" 26 | echo -e "\e[36mAdd Vault License\e[0m" 27 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 28 | echo 29 | else 30 | if [ "${1^^}" == "DOIT" ] 31 | then 32 | echo -e "---[ \e[93m\e[1mCreating User \e[36m$tUser \e[0m]---\e[32m" 33 | ~/bin/gam/gam create user $tUser firstname $firstName lastname $lastName org $tOrg 34 | echo "* $timestamp * $tUser - created ($tOrg)" >> ~/gam-data/gam-data.log 35 | ~/bin/gam/gam create alias $tAlias user $tUser 36 | echo "* $timestamp * $tUser - added alias of $tAlias" >> ~/gam-data/gam-data.log 37 | ~/bin/gam/gam update group $tGroup add member $tUser 38 | echo "* $timestamp * $tUser - added to group $tGroup" >> ~/gam-data/gam-data.log 39 | ~/bin/gam/gam user $tUser add license VAULT 40 | echo "* $timestamp * $tUser - Vault license added" >> ~/gam-data/gam-data.log 41 | echo -e "\e[0m---[ \e[93m\e[1m Creation Complete for \e[36m$tUser \e[0m]---" 42 | fi 43 | fi 44 | done < $INPUT 45 | IFS=$OLDIFS 46 | -------------------------------------------------------------------------------- /onLeave: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/userterm.csv 3 | TEMP=~/gam-data/orgname.csv 4 | OLDIFS=$IFS 5 | IFS=, 6 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 7 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 8 | while read userEmail userFirst userLast managerEmail managerPhone 9 | do 10 | #domain=${userEmail/*@/ } 11 | #userId=${userEmail/@*/ } 12 | #userId="$(echo -e "${userId}" | sed -e 's/[[:space:]]*$//')" 13 | #domain="$(echo -e "${domain}" | sed -e 's/^[[:space:]]*//')" 14 | #domain="@$domain" 15 | #dateStamp=_onleave_$(date +%Y%m%d) 16 | #newEmail=$userId$dateStamp$domain 17 | ~/bin/gam/gam info user $userEmail | grep "Path:" > $TEMP 18 | line="$(head -1 $TEMP)" 19 | line="${line#'Google Org Unit Path: '}" 20 | if [ -z "$1" ] 21 | then 22 | echo -e "\e[91m\e[7mALERT:\e[0m To be used only for on leave procedure" 23 | echo -e "to process changes use \e[91m./onLeave doit\e[0m" 24 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 25 | echo -e "\e[1mUser on Leave: \e[0m$userEmail" 26 | echo -e "\e[1mDelegate to: \e[0m$managerEmail ($managerPhone)" 27 | echo -e "\e[1mVacation Responder: \e[0m" 28 | echo -e " $userFirst $userLast is out of the office, please contact $userFirst's manager at" 29 | echo -e " <$managerEmail> or by telephone at $managerPhone. \n\n Thank You. \n IEEE Support." 30 | echo -e "\e[1mSet OnLeave and Date $(date +%Y-%m-%d)" 31 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 32 | echo 33 | else 34 | if [ "${1^^}" == "DOIT" ] 35 | then 36 | echo -e "---[ \e[93m\e[1mOn Leave Process for User \e[36m$userFirst $userLast \e[0m]---\e[32m" 37 | echo "* $timestamp * $userEmail - On Leave Process Start" >> ~/gam-data/gam-data.log 38 | ~/bin/gam/gam update user $userEmail suspended off 39 | ~/bin/gam/gam update user $userEmail Status.Status OnLeave Status.Date $(date +%Y-%m-%d) Status.OU $line 40 | echo "* $timestamp * $userEmail - Status set to OnLeave on $(date +%Y-%m-%d)" >> ~/gam-data/gam-data.log 41 | echo -e "\e[36m- Delegate access to Manager\e[0m" 42 | ~/bin/gam/gam user $userEmail delegate to $managerEmail 43 | ~/bin/gam/gam user $managerEmail add calendar $userEmail selected true hidden false 44 | echo "* $timestamp * $userEmail - Delegated email to $managerEmail" >> ~/gam-data/gam-data.log 45 | echo -e "\e[36m- Deprovision $userEmail\e[0m" 46 | ~/bin/gam/gam user $userEmail deprovision 47 | echo "* $timestamp * $userEmail - Revoked all App Passwords, 2 Factor, and OAuth tokens" >> ~/gam-data/gam-data.log 48 | echo -e "\e[36m- Set Vacation Message\e[0m" 49 | ~/bin/gam/gam user $userEmail vacation on subject "$userFirst $userLast is out of the office:" message "$userFirst $userLast is out of the office, please contact $userFirst's manager by email at <$managerEmail> or by telephone at $managerPhone. \n\n Thank You, \n IEEE Support." startdate $(date +%Y-%m-%d) enddate 2099-12-30 50 | echo "* $timestamp * $userEmail - Set vacation responder to $managerEmail ($managerPhone)" >> ~/gam-data/gam-data.log 51 | echo "* $timestamp * $userEmail - On Leave Process Complete" >> ~/gam-data/gam-data.log 52 | echo -e "\e[0m---[ \e[93m\e[1m On Leave Process Complete for \e[36m$userFirst $userLast \e[0m]---" 53 | echo 54 | fi 55 | fi 56 | done < $INPUT 57 | IFS=$OLDIFS 58 | -------------------------------------------------------------------------------- /purgeFrom: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | max=3; 3 | INPUT=~/gam-data/purge-users.csv 4 | OLDIFS=$IFS 5 | IFS=, 6 | [ ! -f $INPUT ] && { 7 | echo "$INPUT file not found"; 8 | exit 99; 9 | } 10 | [ -z "$2" ] && { 11 | echo "Please use the following format to process the purge:"; 12 | echo "./purgeFrom [DOIT]"; 13 | exit 98; 14 | } 15 | while read emailAddress 16 | do 17 | if [ -z "$3" ] 18 | then 19 | echo -e "* \e[93m\e[1mPREVIEW of purge to \e[91m$emailAddress \e[0mfrom \e[91m$1 \e[0m" 20 | echo -e "* to process changes add \e[91mDOIT \e[0m" 21 | ~/bin/gam/gam user $emailAddress delete messages query "from:$1 AND after:$2" max_to_delete $max 22 | else 23 | if [ "${3^^}" == "DOIT" ] 24 | then 25 | echo -e "* \e[93m\e[1mPurging messages to \e[36m$emailAddress \e[0mfrom \e[91m$1 \e[0m" 26 | ~/bin/gam/gam user $emailAddress delete messages query "from:$1 AND after:$2" max_to_delete $max doit 27 | fi 28 | fi 29 | done < $INPUT 30 | IFS=$OLDIFS 31 | -------------------------------------------------------------------------------- /termUser: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/userterm.csv 3 | TEMP=~/gam-data/orgname.csv 4 | OLDIFS=$IFS 5 | IFS=, 6 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 7 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 8 | while read userEmail userFirst userLast managerEmail managerPhone 9 | do 10 | #domain=${userEmail/*@/ } 11 | #userId=${userEmail/@*/ } 12 | #userId="$(echo -e "${userId}" | sed -e 's/[[:space:]]*$//')" 13 | #domain="$(echo -e "${domain}" | sed -e 's/^[[:space:]]*//')" 14 | #domain="@$domain" 15 | dateStamp=_departed_$(date +%Y%m%d) 16 | ~/bin/gam/gam info user $userEmail | grep "Path:" > $TEMP 17 | line="$(head -1 $TEMP)" 18 | line="${line#'Google Org Unit Path: '}" 19 | #newEmail=$userId$dateStamp$domain 20 | if [ -z "$1" ] 21 | then 22 | echo -e "\e[91m\e[7mALERT:\e[0m To be used only for termination procedure" 23 | echo -e "to process changes use \e[91m./termUser doit\e[0m" 24 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 25 | echo -e "\e[1mUnsuspend: \e[0m$userEmail" 26 | echo -e "\e[1mDelegate to: \e[0m$managerEmail ($managerPhone)" 27 | echo -e "\e[1mVacation Responder: \e[0m" 28 | echo -e " $userFirst $userLast is no longer with IEEE, please contact $userFirst's manager at" 29 | echo -e " <$managerEmail> or by telephone at $managerPhone. \n\n Thank You. \n IEEE Support." 30 | echo -e "\e[36mRemove from All Groups\e[0m" 31 | echo -e "\e[36mRemove mobile devices\e[0m" 32 | echo -e "\e[36mMove from $line to /EXEMPT/Departed Staff Hold Normal\e[0m" 33 | echo -e "\e[36mSet Departed & Date $(date +%Y-%m-%d)" 34 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 35 | echo 36 | else 37 | if [ "${1^^}" == "DOIT" ] 38 | then 39 | echo -e "---[ \e[93m\e[1mTermination Process for User \e[36m$userFirst $userLast \e[0m]---\e[32m" 40 | echo -e "\e[36m- Unsuspending User\e[0m" 41 | echo "* $timestamp * $userEmail - Termination Process Start" >> ~/gam-data/gam-data.log 42 | ~/bin/gam/gam update user $userEmail suspended off 43 | echo "* $timestamp * $userEmail - unsuspended" >> ~/gam-data/gam-data.log 44 | ~/bin/gam/gam update user $userEmail Status.Status Departed Status.Date $(date +%Y-%m-%d) Status.OU $line 45 | echo "* $timestamp * $userEmail - Status set to Departed on $(date +%Y-%m-%d)" >> ~/gam-data/gam-data.log 46 | echo -e "\e[36m- Remove from All Groups\e[0m" 47 | ~/bin/gam/gam user $userEmail delete groups 48 | echo "* $timestamp * $userEmail - all groups removed" >> ~/gam-data/gam-data.log 49 | echo -e "\e[36m- Move to Proper ORG\e[0m" 50 | ~/bin/gam/gam update user $userEmail org "/EXEMPT/Departed Staff Hold Normal" 51 | echo "* $timestamp * $userEmail - Moved to Departed Staff Hold Normal" >> ~/gam-data/gam-data.log 52 | echo -e "\e[36m- Delegate access to Manager\e[0m" 53 | ~/bin/gam/gam user $userEmail delegate to $managerEmail 54 | echo "* $timestamp * $userEmail - Delegated email to $managerEmail" >> ~/gam-data/gam-data.log 55 | echo -e "\e[36m- Set Vacation Message\e[0m" 56 | ~/bin/gam/gam user $userEmail vacation on subject "$userFirst $userLast is no longer with the IEEE:" message "$userFirst $userLast is no longer with the IEEE, please contact $userFirst's manager by email at <$managerEmail> or by telephone at $managerPhone. \n\n Thank You, \n IEEE Support." startdate $(date +%Y-%m-%d) enddate 2099-12-30 57 | echo "* $timestamp * $userEmail - Set vacation responder to $managerEmail ($managerPhone)" >> ~/gam-data/gam-data.log 58 | ~/bin/gam/gam calendar $userEmail add editor $managerEmail 59 | ~/bin/gam/gam user $managerEmail add calendar $userEmail selected true hidden false 60 | ~/bin/gam/gam create datatransfer $userEmail gdrive $managerEmail privacy_level shared,private 61 | echo -e "\e[36m- Randomize Password for $newEmail\e[0m" 62 | ~/bin/gam/gam update user $userEmail password random 63 | echo "* $timestamp * $userEmail - Password Randomized" >> ~/gam-data/gam-data.log 64 | echo -e "\e[36m- Deprovision $newEmail\e[0m" 65 | ~/bin/gam/gam user $userEmail deprovision 66 | echo "* $timestamp * $userEmail - Revoked all App Passwords, 2 Factor, and OAuth tokens" >> ~/gam-data/gam-data.log 67 | echo -e "\e[36m- Dump Mobile Phones\e[0m" 68 | ~/bin/gam/gam print mobile query "email:$userEmail" >> ~/gam-data/tmp.mobile-data.csv 69 | echo -e "\e[36m- Wipe Account from All Mobile Devices\e[0m" 70 | ~/bin/gam/gam csv ~/gam-data/tmp.mobile-data.csv gam update mobile ~resourceId action account_wipe 71 | rm ~/gam-data/tmp.mobile-data.csv 72 | echo "* $timestamp * $userEmail - Mobile Devices Wiped" >> ~/gam-data/gam-data.log 73 | echo "* $timestamp * $userEmail - Termination Process Complete" >> ~/gam-data/gam-data.log 74 | echo -e "\e[0m---[ \e[93m\e[1m Termination Process Complete for \e[36m$userFirst $userLast \e[0m]---" 75 | echo 76 | echo "Please log into Admin Console and reset sign in cookies for $userEmail" 77 | fi 78 | fi 79 | done < $INPUT 80 | IFS=$OLDIFS 81 | -------------------------------------------------------------------------------- /termUser.extended: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/userterm.csv 3 | TEMP=~/gam-data/orgname.csv 4 | OLDIFS=$IFS 5 | IFS=, 6 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 7 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 8 | while read userEmail userFirst userLast managerEmail managerPhone 9 | do 10 | dateStamp=_departed_$(date +%Y%m%d) 11 | ~/bin/gam/gam info user $userEmail | grep "Path:" > $TEMP 12 | line="$(head -1 $TEMP)" 13 | line="${line#'Google Org Unit Path: '}" 14 | if [ -z "$1" ] 15 | then 16 | echo -e "\e[91m\e[7mALERT:\e[0m To be used only for termination procedure" 17 | echo -e "to process changes use \e[91m./termUser doit\e[0m" 18 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 19 | echo -e "\e[1mUnsuspend: \e[0m$userEmail" 20 | echo -e "\e[1mDelegate to: \e[0m$managerEmail ($managerPhone)" 21 | echo -e "\e[1mVacation Responder: \e[0m" 22 | echo -e " $userFirst $userLast is no longer with IEEE, please contact $userFirst's manager at" 23 | echo -e " <$managerEmail> or by telephone at $managerPhone. \n\n Thank You. \n IEEE Support." 24 | echo -e "\e[36mRemove from All Groups\e[0m" 25 | echo -e "\e[36mRemove mobile devices\e[0m" 26 | echo -e "\e[36mMove from $line to /EXEMPT/Departed Staff Hold Extended\e[0m" 27 | echo -e "\e[36mSet Departed & Date $(date +%Y-%m-%d)" 28 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 29 | echo 30 | else 31 | if [ "${1^^}" == "DOIT" ] 32 | then 33 | echo -e "---[ \e[93m\e[1mTermination Process for User \e[36m$userFirst $userLast \e[0m]---\e[32m" 34 | echo -e "\e[36m- Unsuspending User\e[0m" 35 | echo "* $timestamp * $userEmail - Termination Process Start" >> ~/gam-data/gam-data.log 36 | ~/bin/gam/gam update user $userEmail suspended off 37 | echo "* $timestamp * $userEmail - unsuspended" >> ~/gam-data/gam-data.log 38 | ~/bin/gam/gam update user $userEmail Status.Status Departed Status.Date $(date +%Y-%m-%d) Status.OU $line 39 | echo "* $timestamp * $userEmail - Status set to Departed on $(date +%Y-%m-%d)" >> ~/gam-data/gam-data.log 40 | echo -e "\e[36m- Remove from All Groups\e[0m" 41 | ~/bin/gam/gam user $userEmail delete groups 42 | echo "* $timestamp * $userEmail - all groups removed" >> ~/gam-data/gam-data.log 43 | echo -e "\e[36m- Move to Proper ORG\e[0m" 44 | ~/bin/gam/gam update user $userEmail org "/EXEMPT/Departed Staff Hold Extended" 45 | echo "* $timestamp * $userEmail - Moved to Departed Staff Hold Extended" >> ~/gam-data/gam-data.log 46 | echo -e "\e[36m- Delegate access to Manager\e[0m" 47 | ~/bin/gam/gam user $userEmail delegate to $managerEmail 48 | echo "* $timestamp * $userEmail - Delegated email to $managerEmail" >> ~/gam-data/gam-data.log 49 | echo -e "\e[36m- Set Vacation Message\e[0m" 50 | ~/bin/gam/gam user $userEmail vacation on subject "$userFirst $userLast is no longer with the IEEE:" message "$userFirst $userLast is no longer with the IEEE, please contact $userFirst's manager by email at <$managerEmail> or by telephone at $managerPhone. \n\n Thank You, \n IEEE Support." startdate $(date +%Y-%m-%d) enddate 2099-12-30 51 | echo "* $timestamp * $userEmail - Set vacation responder to $managerEmail ($managerPhone)" >> ~/gam-data/gam-data.log 52 | ~/bin/gam/gam calendar $userEmail add editor $managerEmail 53 | ~/bin/gam/gam user $managerEmail add calendar $userEmail selected true hidden false 54 | ~/bin/gam/gam create datatransfer $userEmail gdrive $managerEmail privacy_level shared,private 55 | echo -e "\e[36m- Randomize Password for $newEmail\e[0m" 56 | ~/bin/gam/gam update user $userEmail password random 57 | echo "* $timestamp * $userEmail - Password Randomized" >> ~/gam-data/gam-data.log 58 | echo -e "\e[36m- Deprovision $newEmail\e[0m" 59 | ~/bin/gam/gam user $userEmail deprovision 60 | echo "* $timestamp * $userEmail - Revoked all App Passwords, 2 Factor, and OAuth tokens" >> ~/gam-data/gam-data.log 61 | echo -e "\e[36m- Dump Mobile Phones\e[0m" 62 | ~/bin/gam/gam print mobile query "email:$userEmail" >> ~/gam-data/tmp.mobile-data.csv 63 | echo -e "\e[36m- Wipe Account from All Mobile Devices\e[0m" 64 | ~/bin/gam/gam csv ~/gam-data/tmp.mobile-data.csv gam update mobile ~resourceId action account_wipe 65 | rm ~/gam-data/tmp.mobile-data.csv 66 | echo "* $timestamp * $userEmail - Mobile Devices Wiped" >> ~/gam-data/gam-data.log 67 | echo "* $timestamp * $userEmail - Termination Process Complete" >> ~/gam-data/gam-data.log 68 | echo -e "\e[0m---[ \e[93m\e[1m Termination Process Complete for \e[36m$userFirst $userLast \e[0m]---" 69 | echo 70 | echo "Please log into Admin Console and reset sign in cookies for $userEmail" 71 | fi 72 | fi 73 | done < $INPUT 74 | IFS=$OLDIFS 75 | -------------------------------------------------------------------------------- /termUser.never: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=~/gam-data/userterm.csv 3 | TEMP=~/gam-data/orgname.csv 4 | OLDIFS=$IFS 5 | IFS=, 6 | timestamp=$(date +%Y-%m-%d@%I:%M%p) 7 | [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } 8 | while read userEmail userFirst userLast managerEmail managerPhone 9 | do 10 | dateStamp=_departed_$(date +%Y%m%d) 11 | ~/bin/gam/gam info user $userEmail | grep "Path:" > $TEMP 12 | line="$(head -1 $TEMP)" 13 | line="${line#'Google Org Unit Path: '}" 14 | if [ -z "$1" ] 15 | then 16 | echo -e "\e[91m\e[7mALERT:\e[0m To be used only for termination procedure" 17 | echo -e "to process changes use \e[91m./termUser doit\e[0m" 18 | echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- " 19 | echo -e "\e[1mUnsuspend: \e[0m$userEmail" 20 | echo -e "\e[1mDelegate to: \e[0m$managerEmail ($managerPhone)" 21 | echo -e "\e[1mVacation Responder: \e[0m" 22 | echo -e " $userFirst $userLast is no longer with IEEE, please contact $userFirst's manager at" 23 | echo -e " <$managerEmail> or by telephone at $managerPhone. \n\n Thank You. \n IEEE Support." 24 | echo -e "\e[36mRemove from All Groups\e[0m" 25 | echo -e "\e[36mRemove mobile devices\e[0m" 26 | echo -e "\e[36mMove from $line to /EXEMPT/Departed Staff Hold Indefinite\e[0m" 27 | echo -e "\e[36mSet Departed & Date $(date +%Y-%m-%d)" 28 | echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--" 29 | echo 30 | else 31 | if [ "${1^^}" == "DOIT" ] 32 | then 33 | echo -e "---[ \e[93m\e[1mTermination Process for User \e[36m$userFirst $userLast \e[0m]---\e[32m" 34 | echo -e "\e[36m- Unsuspending User\e[0m" 35 | echo "* $timestamp * $userEmail - Termination Process Start" >> ~/gam-data/gam-data.log 36 | ~/bin/gam/gam update user $userEmail suspended off 37 | echo "* $timestamp * $userEmail - unsuspended" >> ~/gam-data/gam-data.log 38 | ~/bin/gam/gam update user $userEmail Status.Status Departed Status.Date $(date +%Y-%m-%d) Status.OU $line 39 | echo "* $timestamp * $userEmail - Status set to Departed on $(date +%Y-%m-%d)" >> ~/gam-data/gam-data.log 40 | echo -e "\e[36m- Remove from All Groups\e[0m" 41 | ~/bin/gam/gam user $userEmail delete groups 42 | echo "* $timestamp * $userEmail - all groups removed" >> ~/gam-data/gam-data.log 43 | echo -e "\e[36m- Move to Proper ORG\e[0m" 44 | ~/bin/gam/gam update user $userEmail org "/EXEMPT/Departed Staff Hold Indefinite" 45 | echo "* $timestamp * $userEmail - Moved to Departed Staff Hold Indefinite" >> ~/gam-data/gam-data.log 46 | echo -e "\e[36m- Delegate access to Manager\e[0m" 47 | ~/bin/gam/gam user $userEmail delegate to $managerEmail 48 | echo "* $timestamp * $userEmail - Delegated email to $managerEmail" >> ~/gam-data/gam-data.log 49 | echo -e "\e[36m- Set Vacation Message\e[0m" 50 | ~/bin/gam/gam user $userEmail vacation on subject "$userFirst $userLast is no longer with the IEEE:" message "$userFirst $userLast is no longer with the IEEE, please contact $userFirst's manager by email at <$managerEmail> or by telephone at $managerPhone. \n\n Thank You, \n IEEE Support." startdate $(date +%Y-%m-%d) enddate 2099-12-30 51 | echo "* $timestamp * $userEmail - Set vacation responder to $managerEmail ($managerPhone)" >> ~/gam-data/gam-data.log 52 | ~/bin/gam/gam calendar $userEmail add editor $managerEmail 53 | ~/bin/gam/gam user $managerEmail add calendar $userEmail selected true hidden false 54 | ~/bin/gam/gam create datatransfer $userEmail gdrive $managerEmail privacy_level shared,private 55 | echo -e "\e[36m- Randomize Password for $newEmail\e[0m" 56 | ~/bin/gam/gam update user $userEmail password random 57 | echo "* $timestamp * $userEmail - Password Randomized" >> ~/gam-data/gam-data.log 58 | echo -e "\e[36m- Deprovision $newEmail\e[0m" 59 | ~/bin/gam/gam user $userEmail deprovision 60 | echo "* $timestamp * $userEmail - Revoked all App Passwords, 2 Factor, and OAuth tokens" >> ~/gam-data/gam-data.log 61 | echo -e "\e[36m- Dump Mobile Phones\e[0m" 62 | ~/bin/gam/gam print mobile query "email:$userEmail" >> ~/gam-data/tmp.mobile-data.csv 63 | echo -e "\e[36m- Wipe Account from All Mobile Devices\e[0m" 64 | ~/bin/gam/gam csv ~/gam-data/tmp.mobile-data.csv gam update mobile ~resourceId action account_wipe 65 | rm ~/gam-data/tmp.mobile-data.csv 66 | echo "* $timestamp * $userEmail - Mobile Devices Wiped" >> ~/gam-data/gam-data.log 67 | echo "* $timestamp * $userEmail - Termination Process Complete" >> ~/gam-data/gam-data.log 68 | echo -e "\e[0m---[ \e[93m\e[1m Termination Process Complete for \e[36m$userFirst $userLast \e[0m]---" 69 | echo 70 | echo "Please log into Admin Console and reset sign in cookies for $userEmail" 71 | fi 72 | fi 73 | done < $INPUT 74 | IFS=$OLDIFS 75 | --------------------------------------------------------------------------------