-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitwarden_auto_en.sh
50 lines (24 loc) · 1.03 KB
/
bitwarden_auto_en.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
#!/bin/bash
if [ ! -f /tmp/bitwarden_userids_current ]; then
echo "user_ids not found!"
fi
echo "Moving current ids to old"
mv /tmp/bitwarden_userids_current /tmp/bitwarden_userids_old
bw login --apikey 1> /dev/null
eval $( bw unlock --passwordenv BW_PASSWORD | grep export | cut -c2- ) 1> /dev/null
list_output=$( bw list org-members --organizationid xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | jq '.' )
memberlist=$( echo "$list_output" | grep id | sed 's/\ *\"id\":\ \"\(.*\)\",/\1/g' )
echo "$memberlist" > /tmp/bitwarden_userids_current
new_memberlist=$( diff /tmp/bitwarden_userids_old /tmp/bitwarden_userids_current | cut -c3- | tail -n +2 )
echo $new_memberlist
echo -en "Now auto-enrolling... \n \n \n"
for i in $new_memberlist
do
echo "$i"
echo "$list_output" | grep -i -B 1 "$i"
done
for i in $new_memberlist
do
eval $( bw unlock --passwordenv BW_PASSWORD | grep export | cut -c2- ) 1> /dev/null
bw confirm org-member "$i" --organizationid xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
done