-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathget_dpdash_accounts.sh
executable file
·58 lines (39 loc) · 1.43 KB
/
get_dpdash_accounts.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# running at predict VM
# 0 8 * * * /opt/dpdash/dpdash/get_accounts.sh tbillah
check_null(){
# check for nullity in server down situation
if [[ `tail -n 1 $1` == *"code 1" ]]
then
exit
fi
}
cd /opt/dpdash/dpdash
source singularity/.env
prefix=dpdash_users_$(date +"%Y%m%d")
echo Name,Username,Email > users/$prefix.csv
/root/mongodb-linux-x86_64-rhel70-4.4.6/bin/mongo --tls --tlsCAFile $state/ssl/ca/cacert.pem --tlsCertificateKeyFile $state/ssl/mongo_client.pem mongodb://dpdash:$MONGO_PASS@`hostname`:27017/dpdmongo?authSource=admin --eval "db.users.find().forEach(u=>print(u.display_name+','+u.uid+','+u.mail))" | tail -n +5 >> users/$prefix.csv
check_null users/$prefix.csv
for to in $@
do
echo '' | mailx -s $prefix -a users/$prefix.txt -r [email protected] -- [email protected]
done
# generate list of new registrants
current_list=users/dpdash_users_$(date +"%Y%m%d").csv
past_list=`ls users/dpdash_users_*.csv | tail -n 2 | head -n 1`
check_null $past_list
current_number=`cat $current_list | wc -l`
past_number=`cat $past_list | wc -l`
if [ $current_number -gt $past_number ]
then
ind=$(( past_number+1 ))
notify=1
fi
if [ ! -z $notify ]
then
for to in $@
do
# sed -n ${ind},${current_number}p $current_list
sed -n ${ind},${current_number}p $current_list | mailx -s "New DPdash registrants: verify their NDA DUC" -r [email protected] -- [email protected]
done
fi