On Fri, May 01, 2020 at 06:26:52AM +0000, Mike Gabriel wrote:
> Here is a slight change...
>
>
> ```
> #!/bin/bash
>
> set -e
>
> declare -a hosts
> num_hosts=0
> while read KEY VALUE ; do
> case "$KEY" in
> dn:) let "num_hosts+=1" ;;
> cn:) hosts[$(($num_hosts-1))]="$VALUE" ;;
> "")
> :
> ;;
> esac
> done < <(ldapsearch -xLLL "objectclass=dhcpHost")
>
> # add gateway host manually
> hosts[$num_hosts]=gateway
>
> # and also tjener...
> hosts[$num_hosts+1]=tjener
>
> printf -v hosts_str -- ',,%q' "${hosts[@]}"
> hosts_str=$(echo $hosts_str | tr 'A-Z' 'a-z')
>
> for i in $(basename -a /etc/debian-edu/host-keytabs/* | sed
> 's#.intern.keytab##') ; do
> match_value=$(echo $i | tr 'A-Z' 'a-z')
> if [[ ! "${hosts_str},," =~ ",,${match_value},," ]]; then
> kadmin.local delprinc host/$i.intern@INTERN
> kadmin.local delprinc nfs/$i.intern@INTERN
> rm /etc/debian-edu/host-keytabs/$i.intern.keytab
> fi
> done
> ```
>
> The match_value part in the loop got introduced. We need to keep the
> case-sensitive string for exactly matching the file name and the principal
> name. But for matching, we want all to be lower-case.
Good. Please commit.
Wolfgang
Attachment:
signature.asc
Description: PGP signature