Adding duplicate-finder script (#2550)

* Adding duplicate-finder script
* removing unused constant and updated doctstring
This commit is contained in:
James Hodgkinson 2024-02-20 18:39:16 +10:00 committed by GitHub
parent 097db70c3d
commit 5794cc5217
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,25 @@
#!/bin/bash
# This script will find all duplicated names in the Kanidm database, handy for upgrading from 1.1.0 RC15 to RC16
if [ -z "${KANIDM_NAME}" ]; then
echo "Setting the KANIDM_NAME env var will save you selecting a user multiple times!" >&2
fi
RES="$(
kanidm group list | grep -E '^name' | awk '{print $2}' || exit 1
kanidm person list | grep -E '^name' | awk '{print $2}' || exit 1
kanidm service-account list | grep -E '^name' | awk '{print $2}' || exit 1
kanidm system oauth2 list | grep -E '^oauth2_rs_name' | awk '{print $2}' || exit 1
)"
DUPES="$(echo "${RES}" | sort | uniq -c | grep -vE '^\s+1' | awk '{print $2}')"
if [ -z "${DUPES}" ]; then
echo "No duplicates found" >&2
exit 0
else
echo "Duplicates found, here's a list" >&2
echo "${DUPES}"
exit 1
fi