-
Notifications
You must be signed in to change notification settings - Fork 3
/
OOO
executable file
·42 lines (42 loc) · 2.1 KB
/
OOO
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
41
42
#!/bin/bash
INPUT=~/gam-data/userterm.csv
OLDIFS=$IFS
IFS=,
timestamp=$(date +%Y-%m-%d@%I:%M%p)
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read userEmail userFirst userLast managerEmail managerPhone
do
domain=${userEmail/*@/ }
userId=${userEmail/@*/ }
userId="$(echo -e "${userId}" | sed -e 's/[[:space:]]*$//')"
domain="$(echo -e "${domain}" | sed -e 's/^[[:space:]]*//')"
domain="@$domain"
dateStamp=_onleave_$(date +%Y%m%d)
newEmail=$userId$dateStamp$domain
if [ -z "$1" ]
then
echo -e "\e[91m\e[7mALERT:\e[0m To be used only for Out of Office procedure"
echo -e "to process changes use \e[91m./OOO doit\e[0m"
echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- "
echo -e "\e[1mOut of Office User: \e[0m$userEmail"
echo -e "\e[1mDelegate to: \e[0m$managerEmail ($managerPhone)"
echo -e "\e[1mVacation Responder: \e[0m"
echo -e " $userFirst $userLast is on leave, please contact $userFirst's manager at"
echo -e " <$managerEmail> or by telephone at $managerPhone. \n\n Thank You. \n IEEE Support."
echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--"
echo
else
if [ "${1^^}" == "DOIT" ]
then
echo -e "---[ \e[93m\e[1mOut of Office Process for User \e[36m$userFirst $userLast \e[0m]---\e[32m"
echo "* $timestamp * $userEmail - Out of Office Process Start" >> ~/gam-data/gam-data.log
echo -e "\e[36m- Set Vacation Message\e[0m"
~/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
echo "* $timestamp * $newEmail - Set vacation responder to $managerEmail ($managerPhone)" >> ~/gam-data/gam-data.log
echo "* $timestamp * $userEmail - Out of Office Process Complete" >> ~/gam-data/gam-data.log
echo -e "\e[0m---[ \e[93m\e[1m Out of Office Process Complete for \e[36m$userFirst $userLast \e[0m]---"
echo
fi
fi
done < $INPUT
IFS=$OLDIFS