/
yaml4info
executable file
·64 lines (50 loc) · 1.42 KB
/
yaml4info
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
57
58
59
60
61
62
63
64
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2018 The Linux Foundation and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
##############################################################################
main() {
while read -r line; do
email="$(echo "$line" | awk -F"," '{print $NF}')"
company=${email#*@}; company=${company%.*};
fullname="$(echo "$line" | awk -F"," '{print $3}')"
lfid="$(echo "$line" | awk -F"," '{print $2}')"
if [[ "$lfid" == "lfservices_releng" ]]; then
continue
else
cat << EOF
- name: '$fullname'
email: '$email'
company: '$company'
id: '$lfid'
timezone: 'Unknown/Unknown'
EOF
fi
done < <(lftools ldap csv "$1")
}
usage() {
cat << EOF
Usage:
$0 ldap-group-name
calls lftools ldap --groups "\$1"
where \$1 is the ldap-group(s) name you would like to build yaml for your INFO.yaml file
Example: $0 'opnfv-gerrit-releng-*' (for multiple groups)
EOF
}
if [[ $# -eq 0 ]] ; then
usage
exit 1
fi
while getopts "h" OPTION
do
case $OPTION in
h ) usage; exit;;
\? ) echo "Unknown option: -$OPTARG" >&2; exit 1;;
esac
done
main "$@"