From ddc9ebaeaf509525c4f38b7079efa3c9ae1a0776 Mon Sep 17 00:00:00 2001 From: Jin-Guk Kwon Date: Thu, 16 Jan 2020 15:59:26 +0100 Subject: [PATCH] Add new file --- vm_list_dual_uid | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 vm_list_dual_uid diff --git a/vm_list_dual_uid b/vm_list_dual_uid new file mode 100644 index 0000000..bf21c0b --- /dev/null +++ b/vm_list_dual_uid @@ -0,0 +1,20 @@ +#!/bin/bash -e +#option $1 is ldap password +#option $2 is ou + + +uid_list=( $(ldapsearch -x -H ldaps://ldap1.ungleich.ch:636 -D cn=manager,dc=ungleich,dc=ch -w $1 -b "ou=$2,dc=ungleich,dc=ch" | grep uid: | awk '{print $2}') ) + +for ((i=0; i<${#uid_list[@]}; i++)) do + uid_temp=$(echo ${uid_list[i]} | sed "s/b'//g" | sed "s/'//g") + list_email[$i]=$(ldapsearch -x -H ldaps://ldap1.ungleich.ch:636 -D cn=manager,dc=ungleich,dc=ch -w $1 -b "uid=${uid_list[$i]},ou=$2,dc=ungleich,dc=ch" | grep mail: | awk '{print $2}' ) + list_vmid=() + list_vmid=( $(onevm list | grep ${list_email[$i]} | grep runn | awk '{print $1}' ) ) + for ((j=0; j<${#list_vmid[@]}; j++)) do + temp=$(onevm show ${list_vmid[$j]} | grep PORT) + temp1="${temp#*\"}" + port="${temp1%%\"*}" + host=$(onevm show ${list_vmid[$j]} | grep HOST | grep ungleich | awk '{print $3}') + echo $uid_temp ${list_vmid[$j]} $port $host >> ~/vm_vnc_list + done +done